且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

删除或替换现有的RouteTable路线

更新时间:2023-12-02 21:04:22

如何在这?

  RouteTable.Routes.Remove(RouteTable.Routes [PostIndex]);

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" }
            );

How do in this?

RouteTable.Routes.Remove(RouteTable.Routes["PostIndex"]);