Delen via


configuration Element (General Settings Schema)

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>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

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 "https://schemas.microsoft.com/.NetConfiguration/v2.0".

Child Elements

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.

ASP.NET Settings Schema

Specifies all elements that are in the ASP.NET configuration schema.

Startup Settings Schema

Specifies all elements that are in the startup settings schema.

Runtime Settings Schema

Specifies all elements that are in the run-time settings schema.

Remoting Settings Schema

Specifies all elements that are in the remoting settings schema.

Network Settings Schema

Specifies all elements that are in the network settings schema.

Cryptography Settings Schema

Specifies all elements that are in the crypto settings schema.

Configuration Sections Schema

Specifies all elements that are in the configuration section settings schema.

Trace and Debug Settings Schema

Specifies all elements that are in the trace and debug settings schema.

XML Web Services Settings Schema

Specifies all elements that are in the Web services settings schema.

Parent Elements

None.

Remarks

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.

Default Configuration

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="https://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>

Element Information

Configuration section handler

Does not apply.

Configuration member

Configuration

Configurable locations

Machine.config

Root-level Web.config

Application-level Web.config

Virtual or physical directory–level Web.config

Requirements

Microsoft Internet Information Services (IIS) version 5.0, 5.1, or 6.0

The .NET Framework version 1.0, 1.1, or 2.0

Microsoft Visual Studio 2003 or Visual Studio 2005

See Also

Tasks

How to: Access ASP.NET Configuration Settings Programmatically

Reference

configSections Element (General Settings Schema)

appSettings Element (General Settings Schema)

connectionStrings Element (ASP.NET Settings Schema)

location Element (ASP.NET Settings Schema)

Concepts

ASP.NET Configuration Overview

Securing ASP.NET Configuration

Configuration Files

Editing ASP.NET Configuration Files

ASP.NET Configuration Scenarios

Other Resources

General Configuration Settings (ASP.NET)

ASP.NET Configuration Settings

ASP.NET Web Site Administration

ASP.NET Configuration API