SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have implemented a SPWebProvisioningProvider class which overrides the Provision method for a custom site definition. If I don't run any code, I get the 'select a template' page when I open up my new site collection. So I noticed some examples stating that you should call props.Web.ApplyWebTemplate. But when I do; the code seems to run into an andless loop calling the provisioning provider again, resulting in a stack overflow exception.

No one else seems to be having this problem, so I guess I'm making a mistake somewhere; but where?

share|improve this question
Could you please paste code in Provision method, and also webtemp_<your site>.xml schema file? – Kai Jan 11 '12 at 10:32
I Would strongly advise not to use custom site definitions, but to use webtemplates, as introduced in SharePoint 2010. Site definitions do give a headache when you want to upgrade them, and they may disappear in vNext. See… for more information. Check… for information on how to use them – Bas Lijten Jan 11 '12 at 11:28
Hi Bas, I'm not really using the template, it's empty. The only thing I use it for is feature stapling and firing provisioning code. So I guess I could just as easily use a Web Template instead, won't matter much. – Jasper Jan 11 '12 at 14:24

Sorry, found the answer myself. You need to create 2 configurations, one with the provisioning handler linked and one without. The configuration without provisioning code is hidden and that's the one you want to apply using web.ApplyWebTemplate. That way, the provisioning code won't fire again.

share|improve this answer
please post the code of your solution. – Esteban V Feb 10 '12 at 12:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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