Asp.net mvc 删除或替换RouteTable中的现有路由
我得到了一个ASP.NET MVC 2.0 Preview 1应用程序,并开始创建一些包含自己路线的区域 我想有一种方法来覆盖主项目中的这些路由。当然,我不能用相同的名称添加新路由。我可以看到RouteTable.Routes.Remove(RouteBase项),但不确定如何使用它Asp.net mvc 删除或替换RouteTable中的现有路由,asp.net-mvc,asp.net-mvc-routing,Asp.net Mvc,Asp.net Mvc Routing,我得到了一个ASP.NET MVC 2.0 Preview 1应用程序,并开始创建一些包含自己路线的区域 我想有一种方法来覆盖主项目中的这些路由。当然,我不能用相同的名称添加新路由。我可以看到RouteTable.Routes.Remove(RouteBase项),但不确定如何使用它 //Need to remove "PostIndex" before adding it again routes.MapAreaRoute( "OurAreaNameSpace"
//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" }
);
你在这里面是怎么做的
RouteTable.Routes.Remove(RouteTable.Routes["PostIndex"]);
谢谢!我花了几个小时才找到这个解决办法。它就像一个符咒。