开发者

Get all routes defined in global.asax

开发者 https://www.devze.com 2022-12-18 14:17 出处:网络
I am using webformrouting in my asp.net c# application. In my global.asax file i define a couple of routes.

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

精彩评论

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