O'Reilly logo

ASP.NET 4 24-Hour Trainer by Toi B. Wright

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required