Introducing ASP.NET Configuration         
                                             
The XML-based Web.config file holds Web application configuration settings.






















These XML-based text files allow you to control many settings of how your Web application runs. The Web.
config can easily be opened, viewed and edited using simple tools like Notepad by developers as well as
systems administrators (once deployed). They are case-sensitive and “well formed”, which means they
follow all the rules of a well-formed XML document. Web.config files support inheritance and polymorphism.

Editing a Web.config file is tedious and error-prone. The settings are space-sensitive, case-sensitive and must
be in the correct order within the file. If .NET does not like what is finds in the Web.config file, it basically
stops using it. Visual Studio will help you edit the Web.Config file with IntelliSense.

A Web.config file inherits all settings defined in parent Web.config files. For example, you may have a Web.
config file at the root of your Web application. A Web.config file in a sub folder can choose to “override” one
or more settings defined in the parent Web.config file. Specifically, the Web.config file can add, delete (clear),
or change existing settings that it would normally inherit. Alternatively, a simpler method may be to have the
parent Web.config file include special settings for specified subfolders and their files. A Web.config file also
exists at the root of the IIS “Web Site”, which is one level above all of the virtual folders.

There is one master Web.config file that all IIS Web sites ultimately inherit from, located here:






























This file offers setting for all IIS Web sites created on a server. Even this file, however, inherits settings from
machine.config, found in the same folder. Machine.config holds is the true base configuration file that holds
base settings for all .NET applications (Windows, Web, etc.) for a machine.

The Web.config file is optional. If a Web application chooses not to add/modify/delete settings define at the
IIS Web Site level, the default settings are used.

Visual Studio Web Developer Express (and higher) includes WAT (Web Site Administration Tool) for editing
the local Web.config file.





















Notice how WAT is based on the URL of the Web application. The Home tab merely includes three
ambiguous links to the other three tabs, in case you have trouble clicking on them! Essentially, WAT is a
Web application that exposes some of the Web.config settings with user-friendly Web controls. It allows you
to configure tracing/debugging, set up an error page, adjust email and security and select ASP.NET providers.
      
IIS 5.0 (Windows 2000), 5.1 (Windows XP), 6.0 (Windows 2003) and 7.0 (Vista and Windows 2008) offer
much more complete editors for changing setting in the Web.config file. These editors are based on Windows
dialog boxes (not Web pages) and offer immediate feedback on submitted data. They also allow you to
configure almost all Web.config settings at the virtual directory, IIS Web site level and machine level. For
example, these editors allow you to configure session variables, machine encryption keys, connection strings
and more. This is especially important for IIS 7.0, since IIS 7.0 also has its own configuration settings that
you (as a developer) need be aware of.

Using either editor, these settings are automatically saved off to the Web.config file without the hassles of
case-sensitive, space-sensitive and XML element ordering issues. Important: any changes made to a Web.
config file on a production server will force .NET to restart the Web application, thus causing all active
sessions to be dropped! Perform these changes in the wee early hours, depending on your client base. We will
cover IIS configuration in-depth in an upcoming IIS chapter.
ASP.NET Configuration
Table of Contents
Copyright (c) 2008.  Intertech, Inc. All Rights Reserved.  This information is to be used exclusively as an
online learning aid.  Any attempts to copy, reproduce, or use for training is strictly prohibited.
Courseware
Training Resources
Tutorials
Services