INFO: ASP.NET Configuration Overview
This article was previously published under Q307626
This article refers to the following Microsoft .NET Framework Class
Library namespace:
On This PageSUMMARY This article provides an introduction to the ASP.NET page
framework. For additional ASP.NET overviews, refer to the following Microsoft Knowledge Base article: 305140 (http://support.microsoft.com/kb/305140/EN-US/) INFO: ASP.NET Roadmap
MORE INFORMATION Configuration involves everything from application settings
such as database connections to security details and information about how
errors should be handled. Configuration files provide a location for
computer-specific and application-specific information that you can change
without having to recompile code. This article addresses the following configuration topics:
Configuration: What's NewIn contrast to Active Server Pages (ASP) application settings that are stored in the Microsoft Internet Information Services (IIS) metabase, ASP.NET configuration settings are stored in Extensible Markup Language (XML) files. This provides the following advantages when you need to change configuration settings and deploy applications:
File Format and Configuration HierarchyThere are two types of configuration files with which you should be concerned for ASP.NET applications: Machine.config and Web.config. Both files are XML-based and contain similar configuration sections. However, the Machine.config file contains configuration information about all .NET applications for a specific version of the framework, whereas the Web.config files contain more granular configuration settings about specific ASP.NET applications. The text in Machine.config and Web.config is case-sensitive.For more information about the format of ASP.NET configuration files, refer to the following topic in the .NET Framework Software Development Kit (SDK) documentation:
Format of ASP.NET Configuration Files When a request for an .aspx page is made, the configuration files
are compiled in such a way that a configuration setting in a Web.config file
that is stored in a subdirectory overrides a setting in a Web.config file in an
application directory, which overrides settings on the Web site level and
settings in the Machine.config file. After the configuration settings are
compiled, they are cached for future requests until one of the configuration
files is modified.http://msdn2.microsoft.com/en-us/library/ackhksh7(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/ackhksh7(vs.71).aspx) The following table lists sample configuration file locations for the http://myserver/myapplication/mydir/mypage.aspx URL:
A Web.config file at any level is optional, but a Machine.config file is required. For more information about configuration hierarchy, refer to the following topic in the .NET Framework SDK documentation:
Hierarchical Configuration Architecture To apply configuration settings to specific resources, use a <location> tag with an appropriate path attribute. You can use the path
attribute to identify a specific file or child directory to which unique
configuration settings apply.http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconhierarchicalconfigurationarchitecture.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconhierarchicalconfigurationarchitecture.asp) For more information about the <location> tag, refer to the following topic in the .NET Framework SDK documentation:
Configuration <Location> Settings http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconconfigurationlocationsettings.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconconfigurationlocationsettings.asp) ASP.NET Configuration SectionsThe ASP.NET configuration sections are contained in the <system.web> section, which is contained in the <configuration> tag: The following table lists all of the ASP.NET configuration
sections:
Retrieving Configuration InformationYou can retrieve information that is stored in the configuration file, but the methods vary for the different configuration settings. Some settings are exposed as properties of the intrinsic objects, and other settings are inaccessible because they are internal settings to ASP.NET.For example, you can use the following code to access the <browserCaps> settings through the Request.Browser object: Microsoft Visual Basic .NET Microsoft Visual C# .NET For more information about how to retrieve configuration settings,
refer to the following topic in the .NET Framework SDK documentation:
Accessing Configuration Settings http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpgrfaccessingaspnetconfigurationsettings.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpgrfaccessingaspnetconfigurationsettings.asp) Extending the Configuration SectionThe .NET Framework configuration functionality is fully extendable. There are two ways in which you can extend configuration:
| Article Translations
|
Back to the top
