Modifying Configuration Sections

You can use the WebConfigurationManager class not only when opening a configuration file to read the values of various configuration settings, but you also can use the WebConfigurationManager class to modify existing configuration settings or add new ones.

The Configuration class supports two methods for saving configuration information: the Save() and SaveAs() methods. For example, the page in Listing 34.15 enables you to turn on and off debugging for an application (see Figure 34.10).

Figure 34.10. Modifying the value of the Debug configuration setting.

image

Listing 34.15. ShowConfigModify.aspx

The page in ...

Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.