You want to create and add your own configuration elements to web.config. No predefined element will do, nor will use of the
key/value entries of web.config, as described in Recipe 12.2.
Determine what configuration information you want to store in web.config, create your own custom section handler for parsing the element, add the definition of the section handler to web.config, add the new configuration element to web.config, and use the configuration information in your application.
Determine what configuration information you want to store in web.config.
Use the .NET language of your choice to create a custom section handler class for parsing your newly defined element.
Add the definition of the section handler to the
<configSections> section of web.config.
Add the configuration element to web.config and assign values to its attributes or child elements.
In the code-behind class for your ASP.NET page, use the .NET language of your choice to access and put the custom configuration data to work.
The code we’ve written to illustrate this solution appears in Examples 12-9, 12-10, 12-11, 12-12, 12-13 through 12-14. Examples 12-9 (VB) and 12-10 (C#) show the class for a custom section handler. The changes we’ve made to web.config to have it use the custom section handler are shown in Example 12-11. Example 12-12 shows the .aspx file for a sample web form that displays some custom configuration settings. ...