Chapter 7: Configuration


Overview

Configuration refers to any settings or data required by an application to run. This information can be as simple as the connection string used to connect to a database, or as complex as the number of threads the running process requires. Techniques for configuring applications come in many forms, from using the original system.ini of Microsoft Windows to using the Windows registry. Each approach has advantages and disadvantages.

ASP.NET’s configuration system is XML file–based. Many first-time ASP.NET developers expect to configure ASP.NET using the Microsoft Internet Information Services (IIS) Manager, just as they would with ASP. ASP.NET does not, however, rely on the IIS metabase at all, even though the IIS metabase is also now XML file–based. The ASP.NET configuration system does not require any proprietary tools to update or manage it since an XML-based configuration system easily lends itself to manual editing and updating. You simply open the XML file, make changes, and save the file, and the changes are applied immediately. Again, this is unlike ASP, which required you to stop and start the Web server for the changes to affect the running application.

The ASP.NET configuration was designed to be simple. Following is a sample ASP.NET configuration file used to change the timeout of ASP.NET Session state from 20 minutes to 30 minutes:

<configuration>
<system.web>
<sessionState timeout="30" />
</system.web>
</configuration>

Saving this file as web.config in the root of your application will immediately cause ASP.NET to change the default Session state timeout value from 20 minutes to 30 minutes—without requiring you to restart your application.

If your site runs across multiple servers, changing configuration is equally as easy. Simply copy the web.config configuration file to each of the application directories requiring the modification, and the application will apply the changes as soon as the file update is complete.

Unlike other books that cover all the various configuration settings, this book does not examine the individual configuration settings in detail. Plenty of books address that topic. (Our favorite reference is the machine.config file, which is extensively documented.) Instead we will focus on how the ASP.NET configuration works and how to use the ASP.NET configuration system to store custom settings.




Microsoft ASP. NET Coding Strategies with the Microsoft ASP. NET Team
Microsoft ASP.NET Coding Strategies with the Microsoft ASP.NET Team (Pro-Developer)
ISBN: 073561900X
EAN: 2147483647
Year: 2005
Pages: 144

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net