标签: asp.net-mvc
我在我的视图中使用此代码来枚举路由,但我无法从Route对象获取路由名称。
RouteCollection routes = RouteTable.Routes; foreach(路线中的RouteBase rb) { 路线= rb作为路线;
那么如何才能访问路由名称?
答案 0 :(得分:1)
我也找到了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