ASP.NET configuration data is stored in XML text files that are each named Web.config. Web.config files can appear in multiple directories in ASP.NET applications. These files allow you to easily edit configuration data before, during, or after applications are deployed on the server. You can create and edit ASP.NET configuration files by using standard text editors, the ASP.NET MMC snap-in, the Web Site Administration Tool, or the ASP.NET configuration API.
ASP.NET configuration files keep application configuration settings separate from application code. Keeping configuration data separate from code makes it easy for you to associate settings with applications, change settings as needed after deploying an application, and extend the configuration schema.
For more information about how data is organized in ASP.NET configuration files, see ASP.NET Configuration Files. Available configuration settings are described in the ASP.NET Configuration Settings.
Configuration File Hierarchy and Inheritance
Each Web.config file applies configuration settings to the directory that it is in and to all of the child directories below it. Settings in child directories can optionally override or modify settings that are specified in parent directories. Configuration settings in a Web.config file can optionally be applied to individual files or subdirectories by specifying a path in a location element.
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 .NET Framework. Because each ASP.NET application inherits default configuration settings from the root Web.config file, you need to create Web.config files only for settings that override the default settings.
Note: |
|---|
The root Web.config file inherits some basic configuration settings from the Machine.config file, which is located in the same directory. Some of these settings cannot be overridden in Web.config files. For more information, see
ASP.NET Configuration File Hierarchy and Inheritance.
|
At run time, ASP.NET uses the Web.config files to hierarchically compute a unique collection of configuration settings for each incoming URL request. These settings are calculated only once and then cached on the server. ASP.NET detects any changes to the configuration files and then automatically applies those changes to the affected applications, restarting the applications in most cases. Hierarchical configuration settings are automatically calculated and cached again whenever a configuration file in the hierarchy is changed. The IIS server does not have to be restarted for the changes to take effect unless the processModel section has been changed.
For more information about how the ASP.NET configuration hierarchy works, see ASP.NET Configuration File Hierarchy and Inheritance and ASP.NET Configuration Scenarios.
Directly Editing Configuration Files
Additional Configuration Elements in the ASP.NET 3.5 Web.config file
The Web.config file for an ASP.NET application that targets the .NET Framework version 3.5 contains configuration elements that are not found in the Web.config files for earlier versions. This expanded Web.config file is also created when you open an existing Web site in and upgrade the Web site to target the .NET Framework version 3.5. In that case, Visual Studio updates the application's Web.config file to include the additional configuration elements.
The following table shows the new configuration elements and the changes to configuration elements from earlier versions of the .NET Framework.
Configuration element
|
Changes in version 3.5
|
|---|
system.codedom |
(New section) Specifies how the .NET Framework Code Document Object Model (CodeDOM) should compile the source code at run time.
|
configSections |
(New section) Defines the system.web.extensions section that is used by ASP.NET AJAX to define how Web services are called from client script. For more information, see Web Services in ASP.NET AJAX.
|
assemblies |
(New section in the compilation element) Specifies the collection of assemblies that are referenced when ASP.NET pages are compiled. Assemblies that are new to ASP.NET version 3.5 are included in this section.
|
namespaces |
(Updated section) This section specifies what namespaces are imported by default. The Linq, Linq, and Generic namespaces have been added.
|
controls |
(Updated section) This section registers assemblies that contain controls, and provides a prefix to reference the control, similar to the way the Directives for ASP.NET Web Pages page directive registers controls in an individual page. By default this section registers controls in the Extensions assembly. These include the ListView control and AJAX-related controls.
|
system.webServer |
This section replaces the AJAX-related HTTP handlers and modules that are added in the httpHandlers and httpModules sections. This section makes the handlers and modules available to IIS 7.0 when it runs in Integrated mode.
|
assemblyBinding |
(Updated section) This section directs the runtime to use the ASP.NET AJAX framework that is part of ASP.NET version 3.5 instead of using any earlier version of the ASP.NET AJAX framework.
|