Model view controller MVC中RouteTable的Url模式?

Model view controller MVC中RouteTable的Url模式?,model-view-controller,routes,url-pattern,Model View Controller,Routes,Url Pattern,我有我的路由集合,希望检索给定路由的url模式(在global.asax中定义) 在应用中: var route = RouteTable.Routes["UserIndex"]; Global.asax: routes.MapRoute( name: "UserIndex", url: "u/{userId}" 在web应用程序中,我无法访问global.asax中定义的Url模式(在route对象中)。还有别的办法吗 我问这个问题是因为我需要在模板列表中定义一些要与Knockout.js

我有我的路由集合,希望检索给定路由的url模式(在global.asax中定义)

在应用中:

var route = RouteTable.Routes["UserIndex"];
Global.asax:

routes.MapRoute(
name: "UserIndex",
url: "u/{userId}"
在web应用程序中,我无法访问global.asax中定义的Url模式(在route对象中)。还有别的办法吗

我问这个问题是因为我需要在模板列表中定义一些要与Knockout.js一起使用的路由模式。

尝试以下方法:

Route userRoute = RouteTable.Routes[UserIndex"] as Route;
string pattern = userRoute.Url;