1

我有很多自定义条目要在SharePoint中的Web配置中进行。 有没有一种方法可以以编程方式进行。如 我有 这下如何在SharePoint中为编程添加网页配置文件

<PageParserPath> 
<PageParserPath VirtualPath="/*" CompilationMode="Always" AllowServerSideScript="true"  IncludeSubFolders="true" /> 

还我一个完整的新的部分将被添加名为

<connectionstring> 
entries here 
</connectionstring> 

我怎么能做到这一点程式设计的任何想法,请

回答

0

使用SPWebConfigModification添加:

http://spmatt.wordpress.com/2013/05/22/using-spwebconfigmodification-to-update-the-web-config-in-sharepoint-2013/

你的情况,你会沿着这些路线的东西:

 var httpRuntimeModification = new SPWebConfigModification(); 
     httpRuntimeModification.Path = "configuration/PageParserPath"; 
     httpRuntimeModification.Name = "myModification"; 
     httpRuntimeModification.Sequence = 0; 
     httpRuntimeModification.Owner = "MyAppName"; 
     httpRuntimeModification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNodes; 
     httpRuntimeModification.Value = "<PageParserPath VirtualPath='/*' CompilationMode='Always' AllowServerSideScript='true'  IncludeSubFolders='true' />"; 
     webApp.WebConfigModifications.Add(httpRuntimeModification); 

你可能必须调整中的XPath,因为我不知道在哪里这个元素住在web.config中

你应该使用这个一个功能接收器,您可以在此获得对您的网络应用程序的参考,并且您应该在功能停用时随时删除它们。

相关问题