C# 删除.net mvc中的路由元素

C# 删除.net mvc中的路由元素,c#,.net,asp.net-mvc,asp.net-mvc-3,C#,.net,Asp.net Mvc,Asp.net Mvc 3,从routecollection中删除此路由的方法是什么?我有一个模块化系统,其中一个模块需要覆盖路由,但当我写一条同名的新路由时,它说 名为“主页”的路由已在路由集合中。路由名称必须是唯一的。 参数名称:名称 //home page routes.MapLocalizedRoute("HomePage", "", new { controller = "Home",

从routecollection中删除此路由的方法是什么?我有一个模块化系统,其中一个模块需要覆盖路由,但当我写一条同名的新路由时,它说

名为“主页”的路由已在路由集合中。路由名称必须是唯一的。 参数名称:名称

        //home page
        routes.MapLocalizedRoute("HomePage",
                        "",
                        new { controller = "Home", action = "Index"},
                        new[] { "Test.Web.Controllers" });
        routes.MapLocalizedRoute("HomePage",
                        "",
                        new { controller = "TwoStepCheckout", action = "Index" },
                        new[] { "Test.Plugin.TwoStepCheckout" });
这是模块

*因此,首先我需要删除主页路由(如果存在),并添加新路由,如下所示?但我不知道如何删除它

        //home page
        routes.MapLocalizedRoute("HomePage",
                        "",
                        new { controller = "Home", action = "Index"},
                        new[] { "Test.Web.Controllers" });
        routes.MapLocalizedRoute("HomePage",
                        "",
                        new { controller = "TwoStepCheckout", action = "Index" },
                        new[] { "Test.Plugin.TwoStepCheckout" });

您可以通过执行以下操作将其删除:

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

你确定你只是不想给你的路线起一个不同的名字吗?