Hi
ASP.NET Configuration system is used to describe
the properties and behaviors of various aspects of ASP.NET
applications. Unlike Classic ASP where configuration information was
stored in a binary repository called the IIS metabase, ASP.NET uses
XML-based configuration system that is more accessible and easier to
use. You can configure features, such as Connection Strings,
Authentication Modes, Caching, Debug and Tracing, Custom Errors and
many more.
Benefits of XML-based Configuration files
ASP.NET Configuration system is extensible
and application specific information can be stored and retrieved
easily. It is human readable.
You need not restart the web server when the settings are changed in configuration file.
ASP.NET automatically detects the changes and applies them to the running ASP.NET application.
You can edit Configuration file using simple
text editor. It can be easily exchanged between servers in a typical
web farm scenario.
Configuration Files
ASP.NET configuration data is stored in two primary XML-based files.
These files allow you to easily edit configuration data at any moment even after the application is deployed on server.
Different types of Configuration files
Machine.config: Server or machine-wide configuration file
Web.config: Application configuration files which deal with a single application
Server Configuration file (Machine.config)
Every ASP.NET server installation includes a configuration file named machine.config,
and this file is installed as a part of .NET Framework installation. You can find machine.config in
C:\<Windows>\Microsoft.NET\Framework\\Config\
ASP.NET 2.0 provides another two files
machine.config.default and machine.config.comments. The
machine.config.default acts as a backup for the machine.config file.
The machine.config.comments file contains a description for each
configuration section and explicit settings for the most commonly used
values.
Application Configuration file (Web.config)
Each and Every ASP.NET application has its own
copy of configuration settings stored in a file called Web.config. If
the web application spans multiple folders, each sub folder has its own
Web.config file that inherits or overrides the parent's file settings.
Configuration File Format
Both Machine.config and Web.config share the same XML schema.
Configuration files are divided into multiple sections, with each section being a top-level XML element.
The root level element in a configuration file is always <configuration>.
Configuration file is organized as hierarchy of section handlers, with each section provides a unique functionality.
For ex: <SessionState> section handler handles session state for the application.
Connection Strings
In ASP.NET 1.0/1.1, all connection string information was stored in
the <appSettings> section. However, ASP.NET 2.0 introduces a new
section called <connectionStrings> that stores all kinds of
connection-string information.
<configuration>
<connectionStrings>
<add
name
="CookieDemo"
connectionString
="server=aras02;database=aras02_Db;
uid=freelance91;pwd=freelance91"/>
</connectionStrings>
</configuration/>
Session State
You can configure session information using the <sessionState> element.
ASP.NET 2.0 introduces new Session state mode called custom mode which allows developer to persist state in any permanent store
like XML or databases like Oracle, DB2 using a custom written provider class.
<sessionState
mode
="StateServer"
cookieless
="false"
timeout
="20"
stateConnectionString="tcpip=aras02:42424"
stateNetworkTimeout="60"
sqlConnectionString
=""
/>
Compilation Model Configuration
ASP.NET Compilation Settings can be configured using the <compilation> element.
You can configure various options like debug assemblies, default language to use in dynamic compilation model
and other compiler options like compiling custom resource files.
Custom Errors
When the ASP.NET application fails, the ASP.NET
page can show the default error page with the source code and line
number. We can prevent this kind of error messages by configuring
<customErrors> element which allows for defining custom error
messages in an ASP.NET application.
<customErrors
mode="[on/off/RemoteOnly]"
defaultRedirect="[URL]">
<error
statusCode="[statusCode]"
redirect="[URL]"
/>
</customErrors>
Authentication
You can configure security model for your application using <authentication> element.
ASP.NET supports three forms of authentication. They are:
Windows authentication
Passport authentication
Forms Authentication
You can disable authentication by setting mode attribute = "none"
Custom Application Specific settings
Every web application must store some application-specific information for its runtime use.
The "appSettings" section provides a way to define custom application settings for an ASP.NET application.
<appSettings>
<add
key="[key]"
value ="[Value]"/>
</appSettings
>
Different ways of specifying ASP.NET Configuration
ASP.NET provides hierarchical model for specifying configuration data.
Each lower level in hierarchy can override the settings defined in upper level in the hierarchy.
It also inherits the settings from parent level in hierarchy.
Machine.config->Web.config (root folder) ->Web.config (sub directory)
Specify at the machine level(machine.config) which apply for all applications hosted on machine
Specify at the application level(web.config) which apply for single application(root directory level)
Specify at the sub directory level(web.config) which apply for application sub directory
In ASP.NET 1.0/1.1, Frame work provided API's that enabled you only to read information from the configuration file.
You had no way to write information into the configuration file.
You have to manually change settings in configuration files which is error prone due to XML tags, case-sensitivity
However ASP.NET 2.0 is shipped with API's which
are capable to manipulate the configuration information settings in
local machine or remote machine.
Different ways to create and Edit the Configuration files:
ASP.NET MMC Snap-in
Web site Administration tool
ASP.NET Configuration API (Programmatic configuration)
Text Editors (Visual Studio IDE)
Configuration files are based on XML, the elements that describe the configuration are case-sensitive.
Check these links:
http://www.developer.com/net/asp/article.php/3569166
http://www.beansoftware.com/ASP.NET-Tutorials/Configuration-System.aspx
Hope this helps
SAN