SPWebConfigModifications and Manual Config entries don't mix

This is just a short post for my own retention and edification - As it is considered best practice to deploy web.config modifications using the SharePoint object model and calling ApplyWebConfigModifications() and Update() on the SPWebService, I want to make note of a few caveats.

When ApplyWebConfigModifications() is called, SharePoint behind-the-scenes looks at the collection of SPWebConfigModifications for EACH web application in the farm and applies those changes. It doesn't matter if you called it for a specific web application; this propagation of config changes is pushed for every web.config that is associated with a web application that contains these SPWebConfigModification entries.

The problem here, is that if you have made any manual configuration changes (for example, if you have to encrypt a section for security purposes), once that ApplyWebConfigModifications() gets called, those entries are reverted back to whatever value they were entered within that SPWebConfigModification entry.

So, the lesson here- if there are config sections that are known to be sections that will be edited by hand or through some external configuration tool, these are probably best left out of the collection of SPWebConfigModifications to be deployed.

Comments

Popular posts from this blog

SharePoint 2010, VS 2010 and Deploying Resources to the App_Global Resources folder

Windows Phone 7 - Impressions and Transparent Lockscreen

Manzanita Vacation - Day 1