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>
}
精彩评论