12

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

1 Answer 1

26

How do in this?

RouteTable.Routes.Remove(RouteTable.Routes["PostIndex"]);
1
  • Thanks a lot! It took me several hour to find this solution. It works like a charm. Aug 23, 2013 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.