SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question


share|improve this answer

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.
share|improve this answer
I was researching myself the answer, so I would like to complete yours: string defaultPageUrl = Microsoft.SharePoint.Utilities.SPUtility.ConcatUrls(web.ServerRelativeUrl,web.Ro‌​otFolder.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

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:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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