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

Aug 3rd, 2009 by weirdo .

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.

rajeshchoudhary

Written by weirdo .
inditektalk.com

Rate this Article:

Rating: 4.5/5 (2 votes cast)

Add new comment

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

Comments

No comments yet, be the first to comment on this article.

Related Content