我在视图中使用此代码枚举路由,但无法从Route对象中获取路由名称。路由集合为RouteTable.Routes。 foreach (RouteBase rb in routes) { Route route = rb as Route; }那么我如何访问路由名称?
我还发现了Stephen Walter的这个解决方案,它使我们能够保持代码不变(使用MapRoute方法而不是在Stack中另一个解决方案中描述的MapRouteWithName)。 http://stephenwalther.com/blog/archive/2008/08/03/asp-net-mvc-tip-29-build-a-controller-to-debug-your-custom-routes.aspx