2

I have a few child pages, utilizing a master page in the default directory. These children pages are in different subdirectories. How do I get the url of the current page? NOT the master page, but the child page?

balexandre
  • 73,608
  • 45
  • 233
  • 342
WebDevGuy
  • 173
  • 4
  • 18
  • I think you will have to clarify this - when one of the child pages is the current page, then the URL is the URL of the child page. So presumably you don't mean that, but what *do* you mean? – peterG Feb 21 '14 at 00:05
  • This is answered here: http://stackoverflow.com/questions/189062/does-a-masterpage-know-what-page-is-being-displayed – Serialize Feb 21 '14 at 00:09
  • Your question is really confusing. Please post the code what you have tried. ***FYI:*** please do not tag a bunch of unrelated tags to your question. – Win Feb 21 '14 at 00:16

1 Answers1

3

In the good old days we used ServerVariables a lot, and they still handy, for example you can get your page from the URL Path with Request.ServerVariable("PATH_INFO")

this will give you /sessions.aspx for a http://domain.com/session.aspx

or, if you want the server path, you can use Request.ServerVariable("PATH_TRANSLATED") and that will return something like D:\websites\wwwroot\sessions.aspx


Nowdays we tend to use the HttpRequest object for such values, and one of them is the HttpRequest.Url will also have a lot of information that you can use.

You can see my answer to know more about it, but maily, you can see this image:

enter image description here

Community
  • 1
  • 1
balexandre
  • 73,608
  • 45
  • 233
  • 342