Chapter 5. Configuring Your Web Application
Configuration files are used to define Profile properties, store connection strings, configure debugging, define default error pages, and store a host of other settings that control how ASP.NET applications behave. Their primary purpose is to store the settings that you do not want to store in your compiled code.
In this lesson you learn how to configure your web application. I cover the hierarchical nature of web configuration files, how to use the ASP.NET Web site Administration Tool, and how to read a web configuration file programmatically.
WEB CONFIGURATION FILES
At the application level your web configuration is stored in the root folder in a file called web.config
. This is an empty web.config
file:
<?xml version="1.0"?> <configuration> </configuration>
As you can see, the web.config
file is an XML text file with a root element of <configuration>
.
ASP.NET uses a system of configuration files that is hierarchical. At the top of the hierarchy is the machine.config
file. The machine.config
file is located in the following folder:
C:\Windows\Microsoft.NET\Framework\v4.0.21006\Config
The machine.config
file contains hundreds of settings. The settings in the machine.config
file are inherited by all of the applications on the machine that use the .NET Framework. This includes both web applications and other types of applications.
In the same folder as the machine.config
file is a web.config
file. The web.config
file contains settings related to ...
Get ASP.NET 4 24-Hour Trainer now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.