在SharePoint 2010中移除Web config中的配置
下面的例子目的是从SharePoint 2010网站的web.config中移除特定的配置信息。
SPWebConfigModification configModFound = null;
SPWebApplication webApplication = SPWebApplication.Lookup(new Uri(“http://SPSite/”));
Collection modsCollection = webApplication.WebConfigModifications;
// Find the most recent modification of a specified owner
int modsCount1 = modsCollection.Count;
for (int i = modsCount1 – 1; i > -1; i–)
{
if (modsCollection[i].Owner == “User Name”)
{
configModFound = modsCollection[i];
}
}
// Remove it and save the change to the configuration database
modsCollection.Remove(configModFound);
webApplication.Update();
// Reapply all the configuration modifications
webApplication.Farm.Services.GetValue().ApplyWebConfigModifications();
参考资料
Removing configuration Settings from Web config in SharePoint 2010
浙公网安备 33010602011771号