Execute your custom code after instantiating a SharePoint site based on a Site Definition using ExecuteURL

Sometimes you know you can do something, but are completely forgotten how. This is a kind of post to self, so if I search for it again, I will end up on my own blog again. This actually happens 80% of the time when I search for something on SharePoint;-).

When you have a Site Definition, but want to execute code after a site is instantited based on the Site Definition (a first time run after creation), you can add a CAML tag ExecuteURL to your Site Definition that points to an ASPX page in the _layouts directory. This tag must be placed in the ONET.XML file for the Site Definition, in the Configuration section.

In this page you can do things like applying a theme, creation of Site Groups, add users to these groups, or even start an interactive session with the user to request aditional information.

The documentation can be found here in the SharePoint SDK.

3 Comments

Comments have been disabled for this content.