tags:

views:

65

answers:

3

Hi,

How can I get the url of the active aspx page from the code behind so that I can assign it to a string variable?

Does it make a difference in what page-lifecycle stage I call this?

Thanks

+1  A: 

To Get the path

System.Web.HttpContext.Current.Request.Path

Or you can also do..

 Request.Url.AbsoluteUri

And it does not matter in page life cycle.

Nix
+1  A: 

Do you mean something other than Request.Url?

Charles Boyung
+3  A: 

if you're on a page:

Request.Url.ToString();

if you are a class library elsewhere

HttpContext.Current.Request.Url.ToString();

Doesn't matter about lifecycle

BritishDeveloper