.NET application configuration files contain settings specific to an application.
Application configuration files contain settings specific to an application. This file contains configuration settings that the common language runtime reads (such as assembly binding policy, remoting objects, and so on), and settings that the application can read.
The name and location of the application configuration file depend on the application's host, which can be one of the following:
Executable–hosted application.
The configuration file for an application hosted by the executable host is in the same directory as the application. The name of the configuration file is the name of the application with a .config
extension. For example, an application called myApp.exe
can be associated with a configuration file called myApp.exe.config
.
While developing with Visual Studio the file app.config
in a project will be copied to the correctly named configuration file when the project is built.
The file can contain both framework defined and user defined elements (possibly using .NET types to read and write the content).
ASP.NET-hosted application.
ASP.NET configuration files are called web.config
. Configuration files in ASP.NET applications inherit the settings of configuration files in the URL path. For example, given the URL http://www.example.com/aaa/bbb
, where http://www.example.com/aaa
is the Web application, the configuration file associated with the application is located at www.example.com/aaa
. ASP.NET pages that are in the subdirectory bbb
use both the settings that are in the configuration file at the application level and the settings in the configuration file that is in bbb
.
For more information about ASP.NET configuration files, see ASP.NET Configuration
Internet Explorer-hosted application. If an application hosted in Internet Explorer has a configuration file, the location of this file is specified in a tag with the following syntax:
<link rel="ConfigurationFileName" href="location">
In this tag, location is a URL to the configuration file. This sets the application base. The configuration file must be located on the same Web site as the application.