开发者

ASP.NET MVC: Get URLs to RouteTable Routes

I'd like to enumerate al开发者_Python百科l the routes in my application, and get the URLs to them. How can I do this?


Maybe try something like this:

List<string> ApplicationRoutes = new List<string>();

foreach (Route r in RouteTable.Routes)
    ApplicationRoutes.Add(r.Url);

And just to clarify, this will simply give you the URL pattern, not the actual URL.


Routes contain URL-PATTERNS, not URLs. So, info that you're looking for is simply not there.


Phil Haack put together a MVC Route Debugger that might be of use to you. You incorporate it into the DEBUG version of your application and it will display all routes and what route the current request maps to.

http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜