mare
mare

Reputation: 13083

get route name in ASP.NET MVC

I'm using this code in my view to enumerate routes but I am unable to get route names from Route object.

RouteCollection routes = RouteTable.Routes; foreach (RouteBase rb in routes) { Route route = rb as Route;

So how can I get access to route name?

Upvotes: 3

Views: 1624

Answers (1)

mare
mare

Reputation: 13083

I've also found this solution by Stephen Walter which enables us to keep the code unmodified (use MapRoute method instead of MapRouteWithName as described in the another solution at Stack):

http://stephenwalther.com/blog/archive/2008/08/03/asp-net-mvc-tip-29-build-a-controller-to-debug-your-custom-routes.aspx

Upvotes: 1

Related Questions