Created
March 4, 2016 10:30
-
-
Save restlessmedia/b81cb258674142f13889 to your computer and use it in GitHub Desktop.
.Net WebApi catch all route
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.Routes.MapHttpRoute( | |
name: "CatchAll", | |
routeTemplate: "{*.}", | |
defaults: new { controller = "Default" } | |
); | |
public class DefaultController : ApiController | |
{ | |
[HttpGet] | |
public HttpResponseMessage Get() | |
{ | |
return NotFound("Not a valid endpoint"); | |
} | |
[HttpPost] | |
public HttpResponseMessage Post() | |
{ | |
return NotFound("Not a valid endpoint"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment