Created
August 31, 2011 15:01
-
-
Save JeffryGonzalez/1183760 to your computer and use it in GitHub Desktop.
Restful Routes MVC3
This file contains hidden or 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
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); | |
routes.MapRoute( | |
"Destroy", | |
"{controller}/{id}", | |
new { action = "Destroy" }, | |
new { id=@"\d+", httpMethod = new RestHttpMethodConstraint("DELETE") } | |
); | |
routes.MapRoute( | |
"Update", | |
"{controller}/{id}", | |
new { action = "Update" }, | |
new { id=@"\d+", httpMethod = new RestHttpMethodConstraint("PUT") }); | |
routes.MapRoute( | |
"Create", | |
"{controller}", | |
new { action = "Create" }, | |
new { httpMethod = new RestHttpMethodConstraint("POST") }); | |
routes.MapRoute( | |
"Delete", | |
"{controller}/Delete/{id}", | |
new { action = "Delete" }, | |
new { httpMethod=new RestHttpMethodConstraint("GET"), id=@"\d+" } | |
); | |
routes.MapRoute( | |
"Edit", | |
"{controller}/Edit/{id}", | |
new { action = "Edit" }, | |
new { httpMethod = new RestHttpMethodConstraint("GET"), id = @"\d+" }); | |
routes.MapRoute( | |
"New", | |
"{controller}/New", | |
new { action = "New" }, | |
new { httpMethod = new RestHttpMethodConstraint("GET") }); | |
routes.MapRoute( | |
"Show", | |
"{controller}/{id}", | |
new { action = "Show" }, | |
new { httpMethod = new RestHttpMethodConstraint("GET"), id = @"\d+" }); | |
routes.MapRoute( | |
"Index", | |
"{controller}", | |
new { action = "Index" }, | |
new { httpMethod = new RestHttpMethodConstraint("GET") } | |
); | |
//routes.MapRoute( | |
// "Default", // Route name | |
// "{controller}/{action}/{id}", // URL with parameters | |
// new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults | |
//); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment