0

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?

  • Could you please paste code in Provision method, and also webtemp_<your site>.xml schema file? – Sergei Sergeev 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 sharepointchick.com/archive/0001/01/01/… for more information. Check blogs.msdn.com/b/vesku/archive/2010/10/14/… 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
1

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.

|improve this answer|||||
  • please post the code of your solution. – Luis Valencia Feb 10 '12 at 12:22

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.