How to get full home page address of a site collection?
-
06-12-2019 - |
Pregunta
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?
Solución
Try
SPContext.Current.Site.RootWeb.RootFolder.WelcomePage
Otros consejos
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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a sharepoint.stackexchange