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 want to set alerts for all users whenever a new subsite is created under the root site.

I am using the WebProvisioned event, but when I attempt to Update() my new alert I get an error: "There is no web named ". "A first chance exception of type 'System.IO.FileNotFoundException' occurred in Microsoft.SharePoint.dll"

Any help appreciated, thanks.

My code is below:

public override void WebProvisioned(SPWebEventProperties properties)
       if (properties.Web.ParentWeb.Name == "emerg")
           SPSite site = new SPSite(properties.Web.Url);
           SPWeb web = site.OpenWeb(properties.Web.Url);

           SPAlert newAlert = web.Alerts.Add();
           newAlert.AlertFrequency = SPAlertFrequency.Immediate;
           newAlert.AlertType = SPAlertType.List;
           newAlert.EventType = SPEventType.All;
           newAlert.Title = "all alerts - " + properties.Web.Name;
           newAlert.Update(false); //errors here
share|improve this question
up vote 1 down vote accepted
  1. try adding Synchronous in the Elements.xml to ensure operations do not run in separated threads.
  2. Make sure you check for the properties.Web!=null to make sure you actually get the site successfully created.
  3. No need to use SPWeb web= site.OpenWeb again, rather use directly properties.Web. Besides do use Disposable pattern when instiantiating new SPWeb, e.g. put in a using {}.

Hope it helps, C:\Marius

share|improve this answer
thanks that helped. The issue was that I was opening the web as apposed to using the properties.web. However, it now gives me an error "Update() cannot be called until all alert properties are set." It looks like it will not work without the newAlert.List assigned :( Meaning I cannot achieve what I am attempting to do :S – Perplexed May 8 '12 at 20:46
You do need to set the LIST property because your alert is of type SPAlertType.List but on the other hand there a only 2 types available. – Marius Constantinescu - MVP May 8 '12 at 20:53
I may have to go via the SPAudit route then - thanks for your help. – Perplexed May 9 '12 at 14:46

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.