我想仅在web应用程序上应用web.config修改我正在安装我的功能而不是所有的web.configs。我正在使用SPWebService.ApplyWebConfigModifications,我该怎么做?帮助请
答案 0 :(得分:2)
用于部署修改的功能应该是Web应用程序作用域,并且应该具有功能接收器,仅在应用技巧的情况下激活所需Web应用程序上的功能。
答案 1 :(得分:0)
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
using (SPSite site = ((SPSite)properties.Feature.Parent))
{
SPWebApplication webApplication = site.WebApplication;
// webApplication.WebConfigModifications.Clear();
// do modifications, using the feature.GetType().FullName as the Owner
webApplication.Update();
webApplication.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
}
}
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
using (SPSite site = ((SPSite)properties.Feature.Parent))
{
SPWebApplication webApplication = site.WebApplication;
Collection<SPWebConfigModification> entries = webApplication.WebConfigModifications;
for (int i = entries.Count - 1; i >= 0; i--)
{
SPWebConfigModification entry = entries[i];
if (entry.Owner == this.GetType().FullName)
entries.Remove(entry);
}
webApplication.Update();
webApplication.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
}
}
修改强>
为了管理您当前的修改而不直接在SQL Server中,请使用this file并将其复制到该文件夹中: C:\ Program Files \ Common Files \ Microsoft Shared \ web server extensions \ 12 \ TEMPLATE \ ADMIN 并从 http:// centraladministration:PORT /访问它_admin / webconfig.aspx 强>