问题
I got a ASP.NET MVC 2.0 Preview 1 app and started to create some areas which contains their own routes.
I want to have a way to overwrite these routes in the main project. I can of course not add a new route with the same name. I can see the RouteTable.Routes.Remove(RouteBase item) but not sure how to use it.
//Need to remove "PostIndex" before adding it again
routes.MapAreaRoute(
"OurAreaNameSpace",
"PostIndex",
"post/index/{currentPage}",
new { controller = "Post", action = "Index", currentPage = "" },
new string[] { "OurAreaNameSpace.Controllers" }
);
回答1:
How do in this?
RouteTable.Routes.Remove(RouteTable.Routes["PostIndex"]);
来源:https://stackoverflow.com/questions/1417895/remove-or-replace-existing-routes-in-routetable