Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is web.config. How many web.config files can be allowed
to use in an application?

Answer Posted / praveen chandran

System wide configuration settings are defined in the
Machine.config for the .NET Framework. The Machine.config
file is located in the
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\CONFIG folder.
The settings defined in this file are applicable to all
ASP.NET applications in that system.

We can override these default settings by including a
Web.config file in the application's root folder.

By including Web.config files in sub-folders, we can
override the settings defined in the Web.config file in the
application's root folder.

The following are sample section declarations from a
Machine.config file:

<section name="processModel"

type="System.Web.Configuration.ProcessModelConfigurationHandler,

System.Web, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
allowDefinition="MachineOnly"/>

<section name="sessionState"
type="System.Web.SessionState.SessionStateSectionHandler,
System.Web, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
allowDefinition="MachineToApplication"/>

<section name="appSettings"
type="System.Configuration.NameValueFileSectionHandler,
System,
Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"/>

There is an attribute allowDefinition specified in the first
two section declarations with the values: MachineOnly and
MachineToApplication.
What it does mean?

If allowDefinition="MachineOnly", then we can not override
this section either in application level or in folder level.
The only section declared in the Machine.config file with
this settings is processModel.

If allowDefinition="MachineToApplication", then we can
override these sections by the root directory Web.config.
Sections with this setting in Machine.config are
authentication, machineKey, sessionState, trust, and
securityPolicy.

If allowDefinition attribute is omitted in a section
declaration of the Machine.config file, we can override that
section at any level.

We can override the section appSettings at any level and can
access it by using ConfigurationSettings.AppSettings easily.
What is there in the sample project?

The sample source code is a simple ASP.NET web application
with three Web Forms and three Web.config files. The root
folder has a sub folder SubFolder_L1 that has SubFolder_L2,
each has one Web Form and one Web.config file.

Web.config files have different and overridden keys.
Web.config file in the root folder has the following
appSettings declarations:

<appSettings>
<add key="root" value="Root folder's configuration file."/>
<add key="color" value="Blue"/>
</appSettings>

Web.config file in Subfolder_L1 has the following
appSettings declarations:

<appSettings>
<add key="subfolder_l1" value="Subfolder_L1\web.config
file."/>
<add key="color" value="Green"/>
</appSettings>

The color setting is overridden by the subfolder
configuration file. We can read the root element from
Subfolder_L1 or Subfolder_L2 by the following code:

lblConfig.Text = ConfigurationSettings.AppSettings["root"];

But we can not read configuration settings defined in
Subfolder_L1's Web.config file from the root folder.

Is This Answer Correct ?    15 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is http only cookie?

1008


What are the security types in ASP/ASP.NET? Different Authentication modes?

998


What are the 3 levels at which content pages can be attached to Master Page?

1036


Describe the disadvantage of cookies.

974


When using the Pager object, inorder to know which page to go, which property you have to set to grid?

946


What are the Types of objects in ASP

1039


What is a server farm in iis?

990


What is a pixel url?

876


How can we create a website?

897


Explain the difference between Repeater and Data list control in ASP.NET?

1055


What is difference between web config and global asax?

823


What is State Management in .Net and how many ways are there to maintain a state in .Net? What is view state?

996


What are the different types of validation controls in asp.net?

980


What tags do you need to add within the asp:datagrid tags to bind columns manually? How?

920


How to sign out from forms authentication?

996