イベント受信者からのWeb機能の有効化は何もしません
-
28-09-2020 - |
質問
新しいサイトがプロビジョニングされているときに最小のダウンロード戦略機能を自動的に無効にするために実行する次のコードを持っています。残念ながら何も起こりません。ログにエラーがキャプチャされず、例外ファイルには出力されません。
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();
}
}
}
}
.
このがを実行しない理由任意のアイデア?
解決
私はあなたのコードを試してみました、そしてそれは提供されたGUIDでその機能を見つけることができませんでした。だから私はこのプロパティを設定し、それがうまくいった:
web.EnableMinimalDownload = false;
web.Update()
. 所属していません sharepoint.stackexchange