I need to set the homepage to default.aspx in my FeatureActivated event receiver. I tried

rootWeb.RootFolder.WelcomePage = "default.aspx";

but that doesn't seem to be working...this HAS to work in Sharepoint Foundation....i have seen some methods that are not compatible with foundation?



Please check this link to see how to set your home page.

If this does not work, please try to debug and check if your FeatureActivated event gets fired.

Hope this helps


My bad that I did not see that. Anyways can you please try below,

Please use this in feature activating,

SPWeb web = properties.Feature.Parent as SPWeb;
    if (web != null)
            SPFolder rootFolder = web.RootFolder;
            rootFolder.WelcomePage = "YOURCUSTOMURLGOESHERE";

If you would like to resort to your default page during feature deactivation, rootFolder.WelcomePage = "default.aspx";

  • SharePoint Foundation doesn't include publishing features hence the link you posted doesn't apply as it uses SharePoint Server features. Just FYIO. – Sig Weber Oct 18 '12 at 16:07
  • Yep...thats what i thought. There has to be a way to do this in Sharepoint Foundation short of replacing Home.aspx :P – MikeC Oct 18 '12 at 17:59
  • I have edited my original post, to achieve this. – Battlesmith Oct 19 '12 at 1:15
  • 1
    Just a tip, don't put web in a using block. If you didn't create the SPWeb or SPSite using new, it's not yours to dispose! Also, I presume you meant SPFolder rootFolder = web.RootFolder? – Mourndark May 2 '14 at 10:16

maybe slightly off-topic, but since SharePoint 2013 it is possible to set the homepage via the client-side object model (CSOM); one way to do that (which i think is very easy) is to use PnP-PowerShell - there is a PowerShell-cmdlet just to set the home page of a web:


Please see https://github.com/SharePoint/PnP-PowerShell/blob/master/Documentation/SetPnPHomePage.md for details

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.