I have the following code that should run to automatically disable the Minimal Download Strategy feature when a new site is being provisioned. Unfortunately nothing happens. No errors are captured in logs, and nothing is output to an exception file:
public override void WebProvisioned(SPWebEventProperties properties)
{
//base.WebProvisioned(properties);
using(SPWeb web = properties.Web)
{
try
{
Guid mdsGuid = new Guid("87294c72-f260-42f3-a41b-981a2ffce37a");
// also tried with SPFeature
SPFeatureCollection mdsFeature = web.Features;
if (mdsFeature[mdsGuid] != null)
{
// tried this with .Remove(mdsGuid, false) as well
web.Features.Remove(mdsGuid);
web.Update();
}
}
catch(Exception ex)
{
using (System.IO.StreamWriter file = new System.IO.StreamWriter("s:\\exceptions\\fail-" + DateTime.Today + ".txt", false))
{
file.WriteLine(ex);
file.Close();
}
}
}
}
Any ideas why this wouldn't run?