Skip Navigation LinksHome > Categories > Code from a Category

Learn how to configure the ASP.NET Web.config



User Name: codelecturer
Name: Mike Chauhan
Contact Me: www.datawebcoder.com/ContactUs.aspx
Home Page: www.datawebcoder.com
6 years of total IT experience including programming, application development, System Maintenance . 3 years of Experienced and expertise in .Net Framework VB, Visual Basic.Net, ASP.Net 2.0, 3.5 and AD... [More]
Viewed Times: 194
Add Date: 11/08/2011
Web.config file is the configuration file of your ASP.Net Application. Lets go and Learn about web.config file.

The ASP.NET Web.config file is a configuration file which holds the settings for a IIS driven web application. The ASP.NET Web.config file contains information that control module loading/integration, security configuration, session configuration, application language and compilation settings. Before going into the details of the ASP.NET Web.config, we will first discuss common scenarios to utilize the web.config file.


There are many occasions where we need to store global variables in our web applications. These variables are extensively used in many pages of the application. In the classes of each page, we can create static variables to be used as a global variable. This would end up being redundant. We can also create a separate class containing common global variables. Only problem in storing it in a global shared class is that any change would require recompilation. Instead of hard coding these variables to different classes or even a shared class, we can store them globally in the web.config file. By storing them on the ASP.NET Web.config, we can easily change the settings of the application without changing the source code and without recompilation.


Let's break it down into a scenario. Imagine you had a site with multiple pages, multiple user controls, and classes of source code which pointed to a database named Database1. If you were to move to a new database called Database2, we would have to manually change all the pages, classes and controls to the new database name. This would then need to be recompiled and hosted to work. By using the web.config we can store it in a central location establishing easy changeable settings.


Other reasons we would use the web.config is to


enable/disable debug modes
allow impersonation of users
authentication
authorizatoin
configure our web application to handle different types of errors.

What is the Web.Config file?

The web.config file is nothing more than a xml file which holds our IIS web application settings. These settings are used by the IIS and our web application and any virtual directories that have other asp.net web applications. The root of this xml has to be the configuration tag.

Post a Comment

Name: (Optional)
Email: (Optional, you can get an email if somebody replys your comments)*
Email me if somebody respons my comment below:
Details**:
Enter Text
as Below:
(case insensitive, if hard to read, click the "get a new one" button)
 
    
* Your email address will not be shared with any third parties for any reason.
** Maximum 1000 charactors.