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 multiple farms.
Thanks for any help.
The correct order is
ApplyWebConfigModifications()thenUpdate(). Are you encapsulating that code inSPSecurity.RunWithElevatedPrivileges?