asp.mvc change controller name in request path
In my MVC project I have a controller names ProjectController and in pa开发者_JS百科th it looks like /project. I want to have the path for that "/proiect" .. is there any easy way to achieve that without renaming the controller class?
Thanks, Radu
You should be able to accomplish this with routing
routes.MapRoute(
"Misspelling",
"proiect/{action}",
new { controller = "project", action = "index" }
);
Yes, you can modify the rewrite-rules in the Global.aspx file.
routes.MapRoute(
"Default", // Route name
"proiect/{action}/{id}", // URL with parameters
new { controller = "Project", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
精彩评论