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中

你應該使用這個一個功能接收器,您可以在此獲得對您的網絡應用程序的參考,並且您應該在功能停用時隨時刪除它們。

相關問題