简体   繁体   English

如何从Key的RouteTable.Routes集合中获取URL?

[英]How to get url from RouteTable.Routes collection by key?

如何从Key的RouteTable.Routes集合中获取URL?

untested, but seen here link 未经测试,但在这里看到链接

RouteTable.Items[ "myRouteName" ]

to get the Url i would try this 获取网址,我会尝试这个

( (Route) RouteTable.Items[ "myRouteName" ] ).Url

Attention: The items collection can return null if a route with the specified name don't exists. 注意:如果指定名称的路由不存在,则item集合可以返回null。

Try this 尝试这个

RouteCollection routes = RouteTable.Routes;
RouteBase route = routes["key"];

RouteTable.Routes["key"] RouteTable.Routes [“ key”]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM