Take the 2-minute tour ×

When I use SPContext.Current.Site.Url it returns "http://servername"

I need the full homepage URL which is "http://servername/SitePages/Home.aspx"

Does anyone know how to get this programmatically?

share|improve this question

3 Answers 3

up vote 5 down vote accepted



share|improve this answer

To get full url (absolute), you have to :

SPWeb parentWeb=SPContext.Current.Site.RootWeb;
string strFullHomePageUrl= parentWeb.Url+ "/"+ parentWeb.RootFolder.WelcomePage;
share|improve this answer
You can also use SPUrlUtility to build the URL: SPUrlUtility.CombineUrl(parentWeb.Url, parentWeb.RootFolder.WelcomePage) –  Rachel Jul 21 at 8:25

as an addition, in general, if you are inside a page and you want to get full path you always can use:

SPContext.Current.Web.Url + "/" + SPContext.Current.File.Url
share|improve this answer

Your Answer


