【问题标题】:Remove or replace existing routes in RouteTable删除或替换 RouteTable 中的现有路由
【发布时间】:2009-09-13 14:39:05
【问题描述】:

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

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

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

【问题讨论】:

    标签: asp.net-mvc asp.net-mvc-routing


    【解决方案1】:

    这个怎么办?

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

    【讨论】:

    • 非常感谢!我花了几个小时才找到这个解决方案。它就像一个魅力。
    猜你喜欢
    • 2020-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-10
    • 2014-02-24
    相关资源
    最近更新 更多