Saving Web.Config Changes using SPWebConfigurationModification in SharePoint 2010
I have seen numerous examples on some SharePoint blogs regarding the use of the SPWebConfigurationModification class to modify SharePoint's web.config.
However, I noticed some examples call the update method at different times. For example:
myWebApp.Update();
myWebApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
Or
myWebApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
myWebApp.Update();
Which is the correct way? The reason why I ask is because I get a "A web configuration modification operation is already running." error when deploying a custom page which requires modifications to the web.config to be made on load balanced server.
I am sure it is probably due to the fact that the web.config changes are not being saved correctly across mult开发者_Go百科iple farms.
Thanks for any help.
The correct order is ApplyWebConfigModifications()
then Update()
. Are you encapsulating that code in SPSecurity.RunWithElevatedPrivileges
?
精彩评论