MOSS 2007: Changing landing page (default.aspx)

We need to change the landing page of site from default.aspx to one of our customized page. We used the following code:

 

static void Main(string[] args)

        {

            SPSite oSiteCollection = null;

            SPWeb oWibSite = null;

            SPFolder oFolder = null;

 

            try

            {

                oSiteCollection = new SPSite(http://site URL”);

                oWibSite = oSiteCollection.OpenWeb();

                oFolder = oWibSite.RootFolder;

                oFolder.WelcomePage = “document library/page name”;

                oFolder.Update();                         

            }

            catch (Exception e)

            {

                Console.WriteLine(e.Message);

                Console.WriteLine(e.StackTrace);

            }

            finally

            {

                oWibSite.Dispose();

                oSiteCollection.Dispose();

            }           

        }

 

Source: MSDN – forgot URL L

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: