0

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?

  • Does it definitely hit the web.update()? – Michael Colbs Jun 2 '14 at 23:01
  • Yeah it hits web.Update() but nothing happens. – psdpainter Jun 3 '14 at 14:56
  • I'll test your code. – Michael Colbs Jun 3 '14 at 15:02
1

I tried your code and it couldn't find that feature with the provided Guid. So I set this property and it worked:

web.EnableMinimalDownload = false;
web.Update()
  • Do you need to call web.Update() after or does it work with just that? – psdpainter Jun 3 '14 at 15:13
  • Yes. Always call update() or your changes will not be committed – Michael Colbs Jun 3 '14 at 15:16
  • Trying it right now – psdpainter Jun 3 '14 at 15:21
  • Thanks Colbs. Just had to do 3 iisresets for it to kick in. – psdpainter Jun 3 '14 at 15:45
  • haha. 3rd time's a charm. yw – Michael Colbs Jun 3 '14 at 15:47

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.