Thursday, December 30, 2010

Redirect to a Page in custom Site Definition - SharePoint

A Site Definition defines a unique type of Microsoft SharePoint Foundation Web site. There are several site definitions built into SharePoint Foundation. A site definition can include more than one site definition configuration. A SharePoint Foundation Web site is based on particular site definition configuration. For this reason, a site definition may be thought as a family of configurations, although some families contain only one configuration.
  • Site Definitions are the foundations on which all sites and user templates are built.
  • Site Definitions are predefined components needs to be included when a site was created in SharePoint server.
  • Site Definition contains information of Web Part , Lists, Features and navigation bars to be included in the site.

The following are the four site definitions whose configurations can be used to create new Web sites.
  1. STS includes the site definition configurations for, Blank Site, Team Site, and Document Workspace. 
  2. MPS includes the site definition configurations for Basic Meeting Workspace, Blank Meeting Workspace, Decision Meeting Workspace, Social Meeting Workspace, and Multipage Meeting Workspace.
  3. BLOG provides a site definition configuration for blogs.
  4. SGS provides a site definition configuration for Group Work Site.


Redirecting to a custom page, for example like custom settings page, once a new site is created, using custom site definition. This functionality can be also used to have a delayed redirection to site home page, when we perform any site provisioning activities like updating/ modifying the properties of webparts, available on the home page, at runtime.


Assuming that the reader has basic idea working with a custom Site Definition in SharePoint, I m explaining in the below solution. All the configuration we are going to make for achieving this functionality will be done in ONET.XML file only, for our custom site definition with the publishing template.

So here in this solution I m using Publishing Site template, as publishing site has a Redirect page layout, which can be used to create a webpage in the pages library, when the template is being applied.

Step 1: Activating "RedirectPageContentTypeBinding" Feature in the WebFeatures section

This is a very important step, as on activating this feature, the Pages library is configured with Redirect Page Content Type. By default when the Pages library is created in Publishing site, Redirect page content type will not be available. So as to bind this content type "RedirectPageContentTypeBinding" has to be activated, which allows us to create a new page using Redirect Page Layout.

Step 2: Creating a Redirect Page in the pages library

Here we are creating new pages in the Pages Library, using the content type based upon our requirement.

Observe the RedirectURL property, we are explicitly providing the path of default welcome page in the new site going to be created. "~Site" fetches the absolute URL of the site being created, where as "~SiteCollection" fetches the absolute URL of the Site Collection, where the new site is being created.
RedirectURL property can be changed based upon your requirement.

Note: XML folder in your custom Site definition should have the pages above mentioned, along with ONET.XML
Folder structure should be as below:

 --- CustomSiteDefinitionName

Step 3: Specifying Redirect page to open once new site is successfully created

Add the below tag in the Configuration Tag, which specifies, a particular page to be executed once the new site is created. Default behaviour without this tag is to open home page of the site.

Deploy the site definition & create a new site based upon the custom template.

1 comment:

  1. This is my first time i visit here. I found so many interesting stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! Keep up the good work.