SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to get the current page absolute url in sharepoint.. I'm using:


But for:

it returns

Maybe cause layouts folder is the same for all the web applications.. How do I get the correct url?

share|improve this question
Have you tried Page.Request.RawUrl? – Daniel Ziga Sep 17 '12 at 8:34
THANK YOU SO MUCH. RawUrl solved the question :) – MIlena Sep 17 '12 at 9:15
up vote 7 down vote accepted

Code below should do the trick

share|improve this answer
Great! Though it only gives you the relative URL without the http://domain/ part – Dennis G Sep 27 '12 at 16:36





an example is:

using(SPSite site = new SPSite(""))
{     using(SPWeb web = site.OpenWeb())
      string absoluteURL = site.MakeFullUrl(this.Page.Request.Url.ToString());

hope it helps :)

share|improve this answer
The time-battle forced you to update the answer? :) In any case very nice. +1 – eirikb Sep 17 '12 at 9:03
well what can i say it a race against the time and I wanted to make sure he had a selection to choose from instead of HttpContext.Current.Request.Url lol. – ali Sharepoint Sep 17 '12 at 9:07
Thanx but I don't know why HttpContext.Current.Request.Url doesn't work, instead Page.Request.RawUrl did it perfectly. – MIlena Sep 17 '12 at 9:21

Try to use System.Web.HttpContext.Current.Request.Url

It should give you the current pages url.

share|improve this answer
it doesn't give you the url including subsites - maybe sharepoints custom iis pipeline at work – Dennis G Sep 27 '12 at 16:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.