Question

I would like to change my default welcome page on my web, but I would like to avoid activation of feature "Publishing web" on my web just for that small requirement (with that approach I'm familiar).

My custom page is deployed via module (and modul is deployed via feature) and reside in database.

Any suggestion, please?

Was it helpful?

Solution 5

After investigation, conclusion is that there isn't more elegant solution (except activate Publishing web feature, and than define via code) than - deploy page, navigate to page via browser, open page tab on ribbon, and click "Make Homepage" button. And problem solved.

OTHER TIPS

You can do this in code: Set the Welcome Page property of the RootFolder of a web. This property is available in 2007 and 2010

using (SPSite oSiteCollection = new SPSite("http://MyServer/sites/MySubSite")){  
  using(SPWeb oWebsite = oSiteCollection.OpenWeb()){
    SPFolder oFolder = oWebsite.RootFolder; 
    oFolder.WelcomePage = "_layouts/MyFeature/MyWelcome.aspx";
    oFolder.Update();
  }
}

See also http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfolder.welcomepage(v=office.12).aspx

If you are working with SP2010, you can activate the "Default page as wiki" feature, then, on a specific page, you can click on "set as default page".

However, you said the page resides under _layouts... this approach implies you provision your page as a wiki page.

You can do this with code. This was on a WSS 3.0 instance, so no publishing feature available. I have a project that placed my site pages into a document library. On the FeatureActivation method, I have the following code.

   using (SPWeb web = (SPWeb)properties.Feature.Parent)
   {
       siteUrl = web.Url;
       web.Navigation.Home.Url = "pages/home.aspx";
       web.Update();
   }

Set the WelcomePage property of the RootFolder object of the SPWeb object (don't forget to call Update).

That will only work for relative urls which point to a page in a sharepoint list.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top