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?

有帮助吗?

解决方案

Try

SPContext.Current.Site.RootWeb.RootFolder.WelcomePage

其他提示

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
许可以下: CC-BY-SA归因
scroll top