不会在web.config文件中删除SPWebConfigModification

时间:2019-05-30 15:27:38

标签: sharepoint sharepoint-2013

我想使用SPWebConfigModification修改web.config。问题不在于我添加一些修改,而是当我删除它们时。

SPWebConfigModification httpRuntimeModification = new SPWebConfigModification();
httpRuntimeModification.Path = "configuration/system.webServer/modules";
httpRuntimeModification.Name = "add[@name='Session']";
httpRuntimeModification.Sequence = 0;
httpRuntimeModification.Owner = "WebConfigModifications";
httpRuntimeModification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
httpRuntimeModification.Value = "<add name='Session' type='System.Web.SessionState.SessionStateModule' preCondition='' />";
webApplication.WebConfigModifications.Add(httpRuntimeModification);
httpRuntimeModification = new SPWebConfigModification();
httpRuntimeModification.Path = "configuration/runtime/assemblyBinding";
httpRuntimeModification.Name = "dependentAssembly[@name='AssemblyName']";
httpRuntimeModification.Sequence = 0;
httpRuntimeModification.Owner = "WebConfigModifications";
httpRuntimeModification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
httpRuntimeModification.Value = "<dependentAssembly name='AssemblyName'><assemblyIdentity publicKeyToken='PublicKeyToken' culture='Culture' /><bindingRedirect oldVersion='OldVersion' newVersion='NewVersion' /></dependentAssembly>";
webApplication.WebConfigModifications.Add(httpRuntimeModification);

对于第一个节点,删除已正确完成,该节点已添加到configuration / system.webServer / modules中,我可以在web.config文件中看到已删除了该特定节点。

问题出在第二部分,删除代码与第一部分相同,但是web.config文件未更新。

这是我从https://spmatt.wordpress.com/2013/05/22/using-spwebconfigmodification-to-update-the-web-config-in-sharepoint-2013/中学到的文章,删除代码完全相同。

0 个答案:

没有答案