Following on in my series of posts illustrating the various options for storing your application settings in SharePoint 2010, I had a query this week from one of my students.
How can I make web.config changes that apply to only one SharePoint Web Application?
In my example in part 1 (SPWebConfigModification: Persisting Configuration Data in SharePoint 2010) we learn that the Content Service (SPWebService.ContentService) has a WebConfigModifications collection that allows us to add the modifications we want to make.
It’s also possible to make web.config changes that apply to only the IIS Web Sites belonging to the Zones of a specific Web Application. The SPWebApplication object has its own WebConfigModifications collection.
Gotcha: The act of updating is still initiated by the SPWebService.ContentService object. After setting your WebConfigModifications on the SPWebApplication object, you still need to invoke Update() on ContentService.
For more information, have a look at the MSDN article on SPWebConfigModification.