There are two common techniques for adding configuration data to the Web.config file:

The declarative approach adds sections of XML code to the file.
The SPWebConfigModification class to make the modifications programmatically.

This project is an example of the declarative approach to add web.config entries by creating an XML file that contains a set of web.config modifications.

The SharePointRoot\CONFIG folder contains .config and .xml files that are used together to create the web.config file for a Web application in Microsoft SharePoint Foundation. Before copying the web.config file from the \CONFIG folder to the root folder of the Web application, SharePoint Foundation searches the \CONFIG folder for any .xml file with a name in the format webconfig.*.xml and merges its contents with the web.config file. The actions defined in the .xml file are applied to the configuration settings of the Web application. A major advantage to using an .xml file to supplement the web.config file is that customizations are not lost when SharePoint Foundation is upgraded and the web.config file is overwritten.

This example has the following pre-requisites
.NET Framework 3.5
.NET Framework 3.5 SP1

After adding and deplying the WSP please run stsadm -o copyappbincontent


Ivan Sanders
Web: http://www.dimension-si.com
Blog http://dimension-si.com/blog

Last edited Apr 17, 2011 at 7:51 AM by iasanders, version 5