开发者

Get all routes defined in global.asax

I am using webformrouting in my asp.net c# application.

In my global.asax file i define a couple of routes.

My question is, how can i get a list of all routes defined from cod开发者_运维百科e behind (on a page)?


You can access the Routes property on the RouteTable

System.Web.Routing.RouteTable.Routes;


I create a partialView to visualize these in the site to help me from time to time (debugging).

@{ 
    var routes = RouteTable.Routes;
}
@foreach (var route in routes)
{
    var r = (System.Web.Routing.Route)route;
    <h4>@r.Url</h4>
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜