Create the AppConfig Class
Now that you have the configuration section created, it is time to create the AppConfig class. There are three important items that you must do to create this class correctly. First, you must implement the interface IConfigurationSectionHandler (for more information on implementing interfaces see ".NET Interface-based Programming
" in the May/June issue of CoDe Magazine
). Second, you must create an Init method. Third, you must implement the Create method from the IConfigurationSectionHandler interface. Refer to Listing 2
The Init Method
You need to create a method within the AppConfig class to call from the Application_Start event procedure in the Global.asax page. This initializes the "AppConfig" configuration section of the web.config file. Refer to Listing 3
The Create Method
The Create method is called the first time you start an application or anytime that the web.config file is modified. This forces your shared property values to be reloaded with the current values from the web.config file. Refer to Listing 4.
From the Application_Start event procedure in the Global.asax you must call the Init method in the AppConfig class. This method loads the Configuration section named "AppConfig" into a global memory space within the ASP.NET engine. Refer to Listing 5.