2

I need the steps on how to attach event receiver whenever any new site is created. I have not tried this before. I need the detailed step on creating event receiver on site creation

1

If it's creation of a subsite (SPWeb) you want to catch then you can use SPWebEventReceiver.WebProvisioned

But if it's a new SiteCollection then you need to stable a feature to the WebTemplate and then react to the SPFeatureReceiver.FeatureActivated

  • I need to fire the event when any new site is created under this RootSite/site/site/NewSite. Whenever the NewSite is created event sholud be fired. For this do i need to use WebProvisioned or WebAdding method – DRS May 19 '15 at 4:45
  • @Ishani WebAdding happens before the site is created (at all) primary giving you the posibility of preventing the addition. WebProvisioned happens when everything has been created. – Per Jakobsen May 19 '15 at 6:42
  • Thanks.. So do i need to activate any extra feature for WebProvisioned method. I am referring to this link [blog.qumsieh.ca/2010/10/07/… and when i tried to debug after the subsite is created, the breakppoint doesn't get activated in WebProvisioned method – DRS May 19 '15 at 6:59
  • No the only feature to that needs activation is the one with your Event Receiver make sure it's at Site Collection scope (Site in Feature.xml). And it should fire on any subsite created after that. – Per Jakobsen May 19 '15 at 8:40
  • Can you explain why we need to put the scope as site collection – DRS May 19 '15 at 9:49

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.