ASP.NET Configuration Files (Web.config)

Top  Previous  Next


ASP.NET configuration data is stored in XML text files, each named Web.config. Web.config files can appear in multiple directories in ASP.NET applications. Each Web.config file applies configuration settings to its own directory and to all the child directories below it. Settings in the child directories can optionally override or modify settings that are specified in parent directories.

The root of the ASP.NET configuration hierarchy is the systemroot\Microsoft.NET\Framework\versionNumber\CONFIG\Web.config file, which includes settings that apply to all ASP.NET applications that run a specific version of the Microsoft .NET Framework. Because each ASP.NET application inherits default configuration settings from the root Web.config file, you only need to create Web.config files for settings that override the default settings.

Web.Config File Structure

Each configuration file contains nested XML tags and subtags with attributes that specify the configuration settings. All configuration information resides between the <configuration> and </configuration> root XML tags.

Web.config files are plaintext XML files, so you can create or edit configuration settings in the following ways:


use the ASP.NET configuration API.


use the ASP.NET MMC snap-in.


use a text editor or an XML editor to directly edit the configuration files.



Because tags must be well-formed XML, the tags, subtags, and attributes are case-sensitive. Tag names and attribute names are camel-cased, which means that the first character of a tag name is lowercase and the first letter of any subsequent concatenated word or words is uppercase. In most cases, string attribute values are Pascal-case, which means that the first character is uppercase and the first letter of any subsequent concatenated word or words is uppercase. Exceptions are true and false, which are always lowercase.


Custom Sections

The ASP.NET configuration infrastructure makes no assumptions about the types of configuration data that the infrastructure supports. You can create your own handlers to process custom configuration data.


Editing Remote Configuration Files

The ASP.NET configuration API allows your application to modify the configuration files on a remote computer. In particular, you can modify the Machine.config or a Web.config file in any Microsoft Internet Information Services (IIS) application, or its child directories on a remote computer. If the Web.config file does not exist, the returned configuration data consists entirely of inherited settings that apply to the specified path. If your application requests an update on this returned configuration data, a new file is created.

Any Configuration Changes will cause a restart of the Application Domain