删除或替换RouteTable中的现有路由

jes*_*ind 12 asp.net-mvc asp.net-mvc-routing

我有一个ASP.NET MVC 2.0预览1应用程序,并开始创建一些包含自己的路由的区域.

我想有办法在主项目中覆盖这些路线.我当然不能添加具有相同名称的新路由.我可以看到RouteTable.Routes.Remove(RouteBase项)但不知道如何使用它.

//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" }
            );
Run Code Online (Sandbox Code Playgroud)

小智 26

怎么办?

RouteTable.Routes.Remove(RouteTable.Routes["PostIndex"]);
Run Code Online (Sandbox Code Playgroud)