采用“2010年共享点” 我正试图利用SPWebConfig Modification等课程,对包括中央行政管理网在内的农场应用的网络文件进行一些基本改动。 采用网络应用特征的组合文档,由处理修改内容的接收器进行:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
String ownerId = properties.Feature.DefinitionId.ToString();
List<SPWebConfigModification> modsToAdd = new List<SPWebConfigModification>();
#region Authentication Providers
modsToAdd.Add(new SPWebConfigModification()
{
Name = "defaultProvider",
Owner = ownerId,
Path = "configuration/system.web/membership",
Sequence = 0,
Type = SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute,
Value = "FBA_AD_MP"
});
modsToAdd.Add(new SPWebConfigModification()
{
Name = "add [@name="FBA_AD_MP"] [@type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"] [@connectionStringName="ADFBAConnectionString"] [@enableSearchMethods="true"] [@attributeMapUsername="userPrincipalName"]",
Owner = ownerId,
Path = "configuration/system.web/membership/providers",
Sequence = 0,
Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode,
Value = "<add name="FBA_AD_MP" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ADFBAConnectionString" enableSearchMethods="true" attributeMapUsername="userPrincipalName" />"
});
#endregion
#region Connection Strings
modsToAdd.Add(new SPWebConfigModification()
{
Name = "connectionStrings",
Owner = ownerId,
Path = "configuration",
Sequence = 0,
Type = SPWebConfigModification.SPWebConfigModificationType.EnsureSection,
Value = "<connectionStrings />"
});
modsToAdd.Add(WebConfigModificationsUtility.CreateConnectionStringModification(ownerId, 1, "ADFBAConnectionString", properties.Feature.Properties["ADFBAConnectionString"].Value));
#endregion
WebConfigModificationsUtility.AddWebConfigModifications(webApp, modsToAdd.ToArray());
}
网络校正班是这些专题接收器共用的简单用途:
public static void AddWebConfigModifications(SPWebApplication webApp, params SPWebConfigModification[] modificationsToAdd)
{
AddWebConfigModifications(webApp, true, modificationsToAdd);
}
public static void AddWebConfigModifications(SPWebApplication webApp, Boolean persistChanges, params SPWebConfigModification[] modificationsToAdd)
{
foreach (SPWebConfigModification curMod in modificationsToAdd)
{
SPWebService.ContentService.WebApplications[webApp.Id].WebConfigModifications.Add(curMod);
}
if (persistChanges)
{
PersistWebConfigModifications(webApp);
}
}
public static void PersistWebConfigModifications(SPWebApplication webApp)
{
SPWebService.ContentService.WebApplications[webApp.Id].Update();
SPWebService.ContentService.ApplyWebConfigModifications();
}
在内容申请方面,所有项目都在进行罚款,但在试图在中央行政网络应用上激活特征时,SPWebConfig Modificaiton项目从来都不在网上书写。 我已经核实,该守则毫无例外地得到执行。 此外,我的特稿接收人试图取消任何改动,以取消:
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
String ownerId = properties.Feature.DefinitionId.ToString();
WebConfigModificationsUtility.RemoveWebConfigModifications(webApp, ownerId);
}
public static void RemoveWebConfigModifications(SPWebApplication webApp, String ownerId, Boolean persistChanges)
{
RemoveWebConfigModifications(webApp, persistChanges, webApp.WebConfigModifications.Where(x => x.Owner == ownerId).ToArray());
}
public static void RemoveWebConfigModifications(SPWebApplication webApp, Boolean persistChanges, params SPWebConfigModification[] modificationsToRemove)
{
foreach (SPWebConfigModification curMod in modificationsToRemove)
{
SPWebService.ContentService.WebApplications[webApp.Id].WebConfigModifications.Remove(curMod);
}
if (persistChanges)
{
PersistWebConfigModifications(webApp);
}
}
当该守则在中央集束网络应用上运行时,它发现在功能启动方面产生了四项修改,并成功地消除了这些修改,但这些行动中的neither实际上正在改变网络。 浏览网络申请的专栏;甚至连字都没有触及,最后编辑日期的印记在整个过程中始终不变。
我发现各种博客,谈到SPWebConfig Modification等级的继承陷阱,大多数问题都是妥善使用姓名和所有权,以及适当坚持使用SPWebservice固定财产进行变革,但我能按照所有建议的做法告诉Im。 我开始怀疑安普兰有了一个 b子,但我很想知道,在2010年“共同点”中,是否有任何人成功这样做,或者我是否应该打开反镜,试图看到什么?