Skip to content

Instantly share code, notes, and snippets.

@softcraft-development
Created January 18, 2010 21:52
Show Gist options
  • Save softcraft-development/280410 to your computer and use it in GitHub Desktop.
Save softcraft-development/280410 to your computer and use it in GitHub Desktop.
Two RESTful routes for global.asax in ASP.NET MVC
public static void RegisterRoutes(RouteCollection routes)
{
// Matches /Controller/ModelID (with an optional /Action)
routes.MapRoute(
"Details",
"{controller}/{id}/{action}",
new { action = "Details" }
);
// Matches /Controller; typically this represents a list of all models for a particular controller.
routes.MapRoute(
"Index",
"{controller}",
new { controller = "Home", action = "Index"}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment