I have a WebProvisioned event receiver and i do some work in this event receiver. When i create new webs from a console application programmatically, it seems the event receiver does not fire? Is this an expected situation?

1 Answer 1


Possible duplicate of a question on MSDN:
webprovisioned event not firing when subwebs are created programatically or with powershell

Answers from above:

2 things need to consider here

  1. Proper rights of user who runs the power shell command.

  2. Event receiver should not have SPContext object in it. As its null in case of powershell while its available while you directly working through site.

Other notable thing:

Have you tested if the receiver gets triggered but fails to execute? (put a System.Debugger.Break(); at the first line.

Irrelevant to the question, but just to keep the information at one place:

Notes to implementers
Since an event receiver has to be registered with the site collection before it's handlers can execute, the WebAdding and WebProvisioned handlers cannot run when a site collection and its root web site are created.
Ref: SPWebEventReceiver.WebProvisioned method

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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