Domanda

Ho il seguente codice che dovrebbe essere eseguito per disabilitare automaticamente la funzione minima della strategia di download quando viene fornito un nuovo sito.Sfortunatamente non succede nulla.Nessun errore viene catturato nei registri e nulla viene emesso a un file di eccezione:

    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();
                }
            }
        }
    }
.

Qualche idea Perché questo non sarebbe ?

È stato utile?

Soluzione

Ho provato il tuo codice e non è riuscito a trovare quella funzionalità con il GUID fornito.Quindi ho impostato questa proprietà e ha funzionato:

web.EnableMinimalDownload = false;
web.Update()
.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top