URL of requested page

  • Thread starter Thread starter Gary Larimer
  • Start date Start date
G

Gary Larimer

In the Page_Load() event, what Class, method do I use to retrieve the URL of
the current aspx page?

Thanks for any comments\information.
 
Juan said:
re:
!> Response.Write(Request.RawUrl);

That's incorrect.

Request.RawUrl returns a relative url, not an absolute url.
Request.RawUrl example : /virtualdirectory/requestrawurl.aspx

Request.Url.ToString returns the fully qualified url.
Request.Url.ToString example : http://www.server.com/virtualdirectory/requesturl.aspx

Well, to be fair the OP actually didn't specify that he wanted an
absolute url.

There is another difference that should be adressed, though. The RawUrl
property contains the URL that the request from the user contains, while
the Url property contains the URL of the page actually handling the
request. Those might not be the same if you for example use the
HttpContext.RewritePath or HttpServer.Transfer methods.

Which one is better, depends on what information the OP really is after.
 
Back
Top