Created
August 7, 2014 13:34
-
-
Save weiland/8c9e262fc002c919b120 to your computer and use it in GitHub Desktop.
Supports building a REST API with ASP.net MVC 5
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
public class RouteConfig | |
{ | |
public static void RegisterRoutes(RouteCollection routes) | |
{ | |
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); | |
// add this block \o/ | |
routes.MapRoute( | |
name: "single", | |
url: "{controller}/{id}", | |
defaults: new { controller = "Home", action = "Index" }, | |
constraints: new { id = @"^[0-9]+$" } | |
); | |
routes.MapRoute( | |
name: "Default", | |
url: "{controller}/{action}/{id}", | |
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment