2

How to check page is homepage/default page programmatically in C# sharepoint 2010

0
1

SPContext.Current.ContextPageInfo.IsWebWelcomePage

0

To know if a web page is the default page of a SharePoint web site (or any folder) in c# you can use the SPFolder.WelcomePage property. This property return a URL for the default page so you can compare it with the URL of the page you want to test.

Example to test if a page is default for a SharePoint site:

// After you get the SPWeb object...
string defaultPageUrl = web.RootFolder.WelcomePage;
if(defaultPageUrl == <Test Page Url>)
{
  <Test Page Url> is the default page.
}
1
  • I was researching myself the answer, so I would like to complete yours: string defaultPageUrl = Microsoft.SharePoint.Utilities.SPUtility.ConcatUrls(web.ServerRelativeUrl,web.RootFolder.WelcomePage); and <Test Page Url> should be this.Page.Request.Url.AbsolutePath. Then the comparison will work indeed. :)
    – Norbert
    Dec 6 '12 at 10:54
0

You can set a page as home page through sharepoint designer but if you need to check it is home page or not check this link:

https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spcontextpageinfo.iswebwelcomepage.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.