我有一个ASP.NET MVC 2.0 Preview 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" }
            );
有帮助吗?

解决方案

这是怎么做的?

RouteTable.Routes.Remove(RouteTable.Routes["PostIndex"]);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top