We're trying to create a SharePoint 2010 feature on a site collection that when active would execute code each time a web site is created. We're using Visual Studio 2010. The code will set properties on the web site (enable publishing, add some lists, set properties on the lists/libraries). We'd also settle for a console app that would do the same thing. Any ideas? Thanks.


I recommend using a Web Event Receiver to do this, and handle the 'WebProvisioned' method. This can be created as a Site collection scoped feature that will trigger for every sub website that's provisioned.

  • Thanks, James. Can you point me to an example of something similar? – Alex C Dec 9 '11 at 6:17

I have just completed something similar. I create a new site collection based on user input for Title, owner, template, metadata defaults, set auditing and retention policies, etc. This is done via a workflow attached to the request list 'ItemAdded' event. I can probably break the workflow process down into digestible pieces ( it will give me incentive to write a new blog post anyway).

  • Thanks, Tom. Will you be posting sample code? Also, we're doing this with a new web site and not site collection, but I guess it's the same thing. – Alex C Dec 8 '11 at 14:37
  • 1
    I am writing the blog entries for this as we speak. They will be posted on www.stoneyowlsolutions.com/wordpress when I complete them. – Tom Hill Dec 8 '11 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.