Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.Net System.Web.Routing Find actual .aspx Page

Tags:

I'm using System.Web.Routing to have some better URL's and have come across a problem. I need to know the actual page that's handling the request.

for example a request comes in as:

/basketball/home

I need to find the page that handles that request, like:

/management/default.aspx

I'm only using the System.Web.Routing and not MVC. I have a handle to the RequestContext that contains some of the route information, but i don't see what i need.

Thanks in advance.

******* UPDATE *******

I was able to use Context.CurrentHandler which give me "ASP.management_default_aspx", not exactly the page but enough to get the page name.

like image 446
John Boker Avatar asked Apr 06 '09 13:04

John Boker


1 Answers

There is actually another simple way to get the actual page:

String vPath = ((System.Web.Routing.PageRouteHandler)Page.RouteData.RouteHandler).VirtualPath
Do not forget to check Page.RouteData.RouteHandler is not null - while you are getting the page w/o ASP.Net routing but directly.

like image 53
morgan_il Avatar answered Oct 03 '22 01:10

morgan_il