WebProvisioned событие не стремится при создании программных программ SPWEB

sharepoint.stackexchange https://sharepoint.stackexchange.com//questions/53131

  •  10-12-2019
  •  | 
  •  

Вопрос

У меня есть ресивер событий WebProvisioned, и я делаю некоторую работу в этом приемнике событий.Когда я создаю новые полосы из приложения для консоли программно, кажется, что приемник событий не огонь?Это ожидаемая ситуация?

Это было полезно?

Решение

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с sharepoint.stackexchange
scroll top