Setting default landing page through code in sharepoint

Usually when i want to set the page as home page i visit the page URL and open the top navigation bar by clicking the Page option and select the option Make Homepage.
There is also another way to set set the page as home page visit the Site Settings, Site Welcome Page, browse to the destined location select the page and click ok to set it as defalt welcome page or landing page of your site collection in sharepoint.
I wanted to set is through code, via the visual solution, publish the solution activate the feature and you are good to go. In your Visual Studio Solution you will find PropertyBags something like this.

Property bags
Property bags

Open the Elements.xml and add the following code and specify the landing page. Home.aspx in the below example.

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s