【发布时间】:2009-08-14 16:57:45
【问题描述】:
我正在为路线构建 UrlHelper 如best practices
问题是返回值始终为null 在调试的时候发现
Url.RouteUrl("x") 返回 null
Url.RouteCollection["X"] 返回路由
我正在努力:
public static string Category(this UrlHelper helper, int Id, string category)
{
return helper.RouteUrl("X", new {id = Id, category= category});
}
我看不出哪里做错了
【问题讨论】:
-
在您的 Global.asax 中,您实际上是在注册名为“X”的路线吗?
-
是的,有一条路由注册为 routes.MapRoute("X", "/category/{id}/{category}", new {controller="category", action="List"} )
标签: asp.net-mvc asp.net-mvc-routing