Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I need to get the current absolute url of my site from inside code-behind. I tried SPContext.Current.Site.Url and get this error Value does not fall within the expected range.

The goal is to get this url: "http://myspweb.com/mypage.aspx" as result.

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

Absolute : SPContext.Current.Web.Url

[Edit]

BTw there is simlar question already asked @ how to get current URL in SharePoint?

share|improve this answer
add comment

You can use System.Web.HttpContext.Current.Request.Url to get the full url which includes the page.

share|improve this answer
add comment

i able to fix by doing:

SPContext.Current.ListItemServerRelativeUrl
share|improve this answer
add comment

Your Answer

 
discard

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.