SharePoint Site Definition Provisioning Order

When you use site definitions to create sites it's often pretty unclear what the order is in which the sites are provisioned. Knowing the order can be important if you want to make several changes to your site that are dependent on each other. In that case you need to know how to make sure that the changes are executed in the right order.

Site Definition Provisioning Order

  1. Url for the site is created
  2. Global onet.xml is provisioned
  3. Site collection (SPSite) scoped features defined in onet.xml are activated in the order in which they are listed in the onet.xml
  4. Site collection scoped stapled features are activated in random order
  5. Site(SPWeb) scoped features defined in onet.xml are activated in the order in which they are listed in the onet.xml
  6. Site (SPWeb) scoped stapled features in activated in random order
  7. Listinstances defined in onet.xml are created
  8. Modules defined in onet.xml are processed (and thus this is the moment at which the default. aspx file  and other aspx files defined in the modules are added to the site)

This list tells you that if the order in which features are activated is important and you want to use feature stapling you should create dependent features.
This also tells you that the default.aspx page is the last thing that is added to the site. If you want to make changes to this file like moving around web parts on the page, or adding web parts to the page you there are a couple of ways you can go about this:

  1. You can create a feature that provisions the default.aspx page and associate another feature with that one that will contain a featurereceiver that makes changes to the default.aspx page.  – This is the recommended way to go about this
  2. You can create a web control on the master page that will be executed only once – This is recommended for adjusting the MySites. Steve Peschka wrote a great blog post about this
  3. You can use the ExecuteUrl element in the onet.xml. You can add a hyperlink to a custom aspx page to the ExecuteUrl. This page will be opened after the site is created. You can have the custom page make the changes you want to.
  4. You can create a custom provisioning provider, which adds the capability to hook custom code to be executed after the site has been created.


Comments -
  1. Gravatar

    Great post! I was thinking about this order this morning while troubleshooting some site def provisioning and could not find any (good) documentation/posts on the matter.

  2. Gravatar

    Agreed - I was wondering about this yesterday, particularly the order of stapled features, and the modules.

  3. Gravatar

    Great post, can keep people out of trouble!

    Good old ExecuteUrl, was my "2003" way of doing modifications to a site after site creation. Problem is that it was only executed when you created a site from the Web UI, not when you create a site from code... I'm afraid that is still the case...

  4. Gravatar

    Just wanted to point out that ExecuteUrl only works from create.aspx, in other words if you are creating a new site collection from the central administration, it's not gonna work :)

  5. Gravatar

    How do I execute code after the site creation as part of the site definition(SD)? I need to do some operations on a list created from the <List> section of SD.
    Thanks for any help.

  6. Gravatar

    Hi Arshad,

    The easiest way would be to use the ExecuteUrl element in the onet.xml, but you could use any one of the 4 options listed above.

  7. Gravatar

    panerai panerai
    ladies watches ladies watches
    replica patek philippe watches replica patek philippe watches
    longines watches longines watches
    replica breitling watches replica breitling watches
    audemars piguet audemars piguet
    replica panerai watches replica panerai watches
    cartier cartier
    breitling watches breitling watches
    tag heuer tag heuer
    womens watches womens watches
    audemars piguet watches audemars piguet watches
    replica watches replica watches
    replica rolex watches replica rolex watches
    mens watches mens watches
    replica watches replica watches
    rolex watches rolex watches
    patek philippe watches patek philippe watches
    patek philippe patek philippe
    replica tag heuer watches replica tag heuer watches
    omega omega
    longines longines
    omega watches omega watches
    replica cartier watches replica cartier watches
    cartier watches cartier watches
    breitling breitling
    tag heuer watches tag heuer watches
    rolex rolex
    replica longines watches replica longines watches
    panerai watches panerai watches

  8. Gravatar

    SharePoint Site Definition Provisioning Order


Leave a Reply


Please add 5 and 5 and type the answer here: