【问题标题】:get route name in ASP.NET MVC在 ASP.NET MVC 中获取路由名称
【发布时间】:2009-11-30 02:34:26
【问题描述】:

我在视图中使用此代码枚举路由,但无法从 Route 对象获取路由名称。

RouteCollection 路由 = RouteTable.Routes; foreach(路由中的RouteBase rb) { Route route = rb as Route;

那么我怎样才能获得路由名称呢?

【问题讨论】:

    标签: asp.net-mvc


    【解决方案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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-11
      • 1970-01-01
      • 2011-12-17
      • 2016-02-10
      • 2015-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多