Custom Search Tailored for Microsoft .NET  
Aspexception.com Skip Navigation Links
Error RepositoryExpand Error Repository
.NET ResourcesExpand .NET Resources
About
Skip Navigation LinksHome > .NET Resources > ASP.NET Basics > ASP.NET Configuration...
ASP.NET Configuration
Using the features of the ASP.NET configuration system, the developers can configure all of the ASP.NET applications on an entire server, a single ASP.NET application, or individual pages or application subdirectories. The authentication modes, page caching, compiler options, custom errors, debug and trace options, and etc. can be configured through the configuration files.

Configuration File Hierarchy and Inheritance

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.
  • Server configuration file: Machine.config in systemroot\Microsoft.NET\Framework\versionNumber\CONFIG\Web.config
    • Root configuration file: Web.config in systemroot\Microsoft.NET\Framework\versionNumber\CONFIG\Web.config
      • Web site configuration file: Web.config in the root folder of the web site.
The root Web.config file inherits all of the settings in the Machine.config file. The root Web.config file includes settings that apply to all of the ASP.NET applications that run a specific version of the .NET Framework. Each ASP.NET web site inherits default configuration settings from the root Web.config file, and override the default setting in root Web.config if settings are specified in web site Web.config.

Configuration Tools

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 MMC Snap-in
    The Microsoft Management Console (MMC) snap-in for ASP.NET provides a convenient way to manipulate ASP.NET configuration settings at all levels on a local or remote Web server.
    To start the ASP.NET MMC Snap-in, starting the IIS MMC, selecting the web site and then right-click the "Properties", the following interface displayed.
    ASP.NET MMC Snap-in
  • Web Site Administration Tool
    The Web Site Administration Tool is included with the Microsoft Visual Web Developer Web development tool.
    To access the Web Site Administration Tool, on the Website menu, click ASP.Net Configuration.
    Web site admin tool
  • ASP.NET configuration API

Configuration File Syntax

The required root element in every configuration file that is used by the common language runtime and the .NET Framework applications, is <configuration>
<configuration xmlns="schema URL">
   <!-- configuration settings -->
</configuration>
Where the xmlns is optional and the default for ASP.NET version 2.0 is "http://schemas.microsoft.com/.NetConfiguration/v2.0".
The configuration root can contains the following child elements:
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 ASP.NET Settings Schema. Specifies all elements that are in the ASP.NET configuration schema.
<system.web> 
   <anonymousIdentification> 
   <authentication> 
   <authorization> 
   <browserCaps> 
   <caching> 
   <clientTarget> 
   <compilation> 
   <customErrors> 
   <deployment> 
   <deviceFilters> 
   <globalization> 
   <healthMonitoring> 
   <hostingEnvironment> 
   <httpCookies> 
   <httpHandlers> 
   <httpModules> 
   <httpRuntime> 
   <identity> 
   <machineKey> 
   <membership> 
   <mobileControls> 
   <pages> 
   <processModel> 
   <profile> 
   <roleManager> 
   <securityPolicy> 
   <sessionPageState> 
   <sessionState> 
   <siteMap> 
   <trace> 
   <trust> 
   <urlMappings> 
   <webControls> 
   <webParts> 
   <webServices> 
   <xhtmlConformance> 
</system.web>
See system.web for details.
webServices The Web services settings schema defines configuration file elements that control the behavior of ASP.NET Web services and their clients.

Default configuration file

<?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>
Site Map  Copyright © Aspexception.com 2008. All rights Reserved. Terms of Use