Frage

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?

War es hilfreich?

Lösung

Try

SPContext.Current.Site.RootWeb.RootFolder.WelcomePage

Andere Tipps

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

SPWeb parentWeb=SPContext.Current.Site.RootWeb;
string strFullHomePageUrl= parentWeb.Url+ "/"+ parentWeb.RootFolder.WelcomePage;

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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange
scroll top