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

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?


share|improve this question
up vote 1 down vote accepted

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";

share|improve this answer
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
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

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.