Share via


Managing Changes to Configuration Settings

The standard ASP.NET behavior is to restart an application when its configuration settings change. As a result, any state information for that application instance is lost.

Note

If someone who does not have permission to edit the file attempts to change the configuration settings, the application will not restart.

You might want to preserve state information even if the configuration settings are changed. ASP.NET allows you to preserve the information in <appSettings>, <trace>, and any custom sections when you use them in conjunction with an external configuration file. The path for the external file is specified using the configSource section attribute. For more information, see configSource in General Attributes Inherited by Section Elements.

In an external configuration file, you can store configuration settings that you want to be able to change without causing the application to restart. To do so, set the restartOnExternalChanges attribute on the designated configuration section to false. To revert to the standard behavior, set the restartOnExternalChanges attribute to true.

Note

A malicious user might use an application restart to try to disrupt your site. For this reason, you must guard the access to Web.config files by using strict ACLs, such as those listed in Securing ASP.NET Configuration.

For an example of the effects of changing the settings contained in an external configuration file, see Changing Configuration in External File Example.

See Also

Tasks

How to: Create Custom Configuration Sections Using ConfigurationSection

Reference

General Attributes Inherited by Section Elements

appSettings Element (General Settings Schema)

trace Element (ASP.NET Settings Schema)

ConfigSource

RestartOnExternalChanges

appSettings Element (General Settings Schema)

trace Element (ASP.NET Settings Schema)

HttpApplicationState

Concepts

Changing Configuration in External File Example

Securing ASP.NET Configuration