Web.config –configuration file for ASP.NET web application.

Posted Aug 03, 2009 by rajeshchoudhary / comments 0 comments / Print / Font Size Decrease font size Increase font size

This article tells what web.config file is, how to write this and how this file is used by run time to apply settings.

Web.config is an XML file which specifies settings and configuration for your web application written in ASP.NET. You can use any text editor like notepad or xml parser to edit settings in this configuration file. This file contains information regarding security, session, compilation, app language and database connection strings.

The root of web application contains initial Web.config file for that application. Multiples files with same name can be placed in sub directories of web application to control configuration settings for the files placed in that sub directory. Web.config files placed in sub directories can add certain configuration settings to the settings inherited from web.config file of parent directory. The settings in sub directory can override the settings specified in parent directory.

The file %SystemRoot% \Microsoft.NET\Framework\version\CONFIG\ machine.config is default configuration file which contains configuration settings regarding ASP.NET for web server. The configuration settings for every URL resource are determined at run time from the configuration settings specified in the various web.config files in hierarchy up to that file. These settings are then cached for future requests. Any changes in settings specified in web.config files in hierarchy are reflected when a request is made to the resource and this configuration information is re cached for that resource. So there is no need of restart server, sort of things to make changes in settings effective.

appSettings tag of web.config file is used to store connection strings and global variables sort of things. This is something like key value pair.For example

   

This value of connString can be used anywhere throughout your web application using

ConfigurationSettings.AppSettings["ConnString"]; statement.

Happy Coding.

Rate this Article:

Rating: 4.5/5 (2 votes cast)


* You must be logged in order to leave comments, please login or join us.

Comments

No comments yet.



Bookmark and Share
Sign up for our email newsletter
Name:
Email: