ASP.NET

Conclusion : Manage configuration for a specific ASP.NET application

In this section, we saw how to manage configuration for a specific ASP.NET application. The configuration defaults are found within Machine.Config and Machine.Config.Default. When it comes time for the ASP.NET runtime to apply configuration settings to a specific application, ASP.NET looks for overridden configuration settings within an XML file named Web.Config.

The Web.Config file configuring a specific application lives in that application's virtual directory. If you're happy with the way Microsoft set up Web application settings using Machine.Config, you don't need to change anything in Web.Config. However, the default settings (using defaults such as inproc session state Windows authentication) aren't useful for a production Web site.

To change these settings, you may edit the Web.Config file directly (as you had to do in the days of ASP.NET 1.x). However, ASP.NET 2.0 includes new configuration tools that make configuring your site a very straightforward proposition.

We'll encounter ASP.NET configuration many more times in forthcoming tutorials. In fact, we'll visit configuration heavily in the next tutorial on ASP.NET security.

Tutorial 9 Quick Reference

How to view raw configuration files

Look in the Windows directory under Microsoft.NET\Framework\ ver<whatevertheversionis>\config


How to change configuration settings in a specific ASP.NET application

Place a Web.Config file in the application's virtual directory and modify the settings


How to change configuration settings for a specific subdirectory underneath a virtual directory

  1. Place a separate Web.Config file in the subdirectory

    OR

  2. Use the Local element in the virtual directory's Web.Config file


How to modify a Web application's settings using the Web site Administration tool

Select Web site | Administer Web site from the main menu in Visual Studio


How to modify a Web application's settings using the IIS ASP.NET Configuration table

  1. Open the IIS control panel

  2. Highlight the virtual directory setting

  3. Right mouse click to bring up the Properties page

  4. Push the Configuration button

  5. Select the ASP.NET tab


How to retrieve settings from the configuration file

Use the ASP.NET ConfigurationManager class