accessing the Page.routedat, url in asp.net 4.0

TrialUser
TrialUser used Ask the Experts™
on
I have a route setup in the Global.asax as :

routes.MapPageRoute("ChangePassword", "ChangePassword", "~/secure/acChangePwd.aspx")

When I am in this page, I want to access the "ChangePassword" from the route.

My url looks like : http://localhost:3030/ChangePassword.

From this I want to extract "ChangePassword" . How can I do it using Page.routedata.

Please help; thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:

string data = Page.RouteData.Values["ChangePassword"]

Open in new window

Author

Commented:
ChangePAssword is not to query string / routevalue. It is part of the URL. Sorry may be I was not clear.
Let me try my question again with another example:
routes.MapPageRoute("OrderHistory", "OrderHistory/{StatusID}", "~/secure/acOrderHistory.aspx", False, New RouteValueDictionary(New With {.StatusID = ""}))

HEre, I do not want to fetch the statusID, I want to fetch the "OrderHistory" I am trying to figure out in which page, I am inside a user control that is used in several pages. Thanks
Commented:
Can you explain what are you trying to fetch from OrderHistory? Also OrderHistory is a user control?
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Most Valuable Expert 2012
Top Expert 2014
Commented:
Did you try

Request.URL

?

Author

Commented:
Ok I have a user control that I drop in 5 different pages.
http://localhost/OrderHistory
http://localhost/Address
http://localhost/AccountSettings

I want my user control to find out which page I am in and I want to assign this as the header to the page by assigning this to a label like :

lblHeaderText.text = page.routedata.something

Based on which page I am in I want the label to read "OrderHistory" or "Address" or "AccountSettings"

Thanks

Commented:
you can use Request.Url.AbsoluteUri to get u the full path of the page you are in

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial