ASP.NET Syntax ASP.NET Configuration Sections
The required root element in every configuration file that is used by the common language runtime and the .NET Framework applications.
<configuration xmlns = "schema URL">
<!-- configuration settings -->
</configuration>
The following sections describe attributes, child elements, and parent elements.
Attribute |
Description |
xmlns |
Optional String attribute.
Specifies the URL to the XML schema that is used to validate the configuration file. If this attribute is not set, you cannot use F1 Help in Microsoft Visual Studio to open topics for the configuration elements.
The default for ASP.NET verison 2.0 is "http://schemas.microsoft.com/.NetConfiguration/v2.0". |
Element |
Description |
configSections |
Specifies configuration section and namespace declarations. |
appSettings |
Contains custom application settings, such as file paths, XML Web service URLs, or any information that is stored in the .ini file for an application. |
connectionStrings |
Specifies a collection of database connection strings, as name/value pairs, for ASP.NET applications and features. |
location |
Specifies the resource that child configuration settings apply to. This element is also locks configuration settings, which prevents the settings from being overridden by child configuration files. |
system.web |
Specifies the root element for the ASP.NET configuration section and contains configuration elements that configure ASP.NET Web applications and control how the applications behave. |
None.
The configuration element is the required root element in every configuration file that is used by the common language runtime and the .NET Framework applications.
Each configuration file must contain exactly one configuration element.
The following code example shows a basic Web.config file that can be created for any ASP.NET application. The customErrors section is provided in case it is required but is commented out.
<?xml version = "1.0"?>
<configuration xmlns = "http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings />
<connectionStrings />
<system.web>
<compilation debug = "false" />
<authentication mode = "Windows" />
<!--
<customErrors mode = "RemoteOnly" defaultRedirect = "GenericErrorPage.htm">
<error statusCode = "403" redirect = "NoAccess.htm" />
<error statusCode = "404" redirect = "FileNotFound.htm" />
</customErrors>
-->
</system.web>
</configuration>
ASP.NET Configuration