What is web.config. How many web.config files can be allowed
to use in an application?
Answers were Sorted based on User's Feedback
Answer / swaroop
We can have number of config files in an application.
Is This Answer Correct ? | 96 Yes | 12 No |
Answer / subrahmanyam
We can place any number of web.config files in ur
aplication.u can place one web.config in one folder..
like this u can do..
Is This Answer Correct ? | 80 Yes | 7 No |
Answer / mohanraj
The ASP.NET Web.config file is used to define the
configuration settings for an ASP.NET application. ASP.NET
and the .NET Framework use .config files to define all
configuration options. The .config files, including the
ASP.NET Web.config file, are XML files.
Server-wide configuration settings for the .NET Framework
are defined in a file called Machine.config. The settings
in the Machine.config file can be changed and those
settings affect all .NET applications on the server.
Different ASP.NET applications might need different
application settings, that’s why defining those settings in
the Machine.config file, is usually not practical. The
solution for this problem is the ASP.NET Web.config file.
The ASP.NET application configuration settings can be
changed by creating a file called Web.config and saving it
in the root folder of the application. But what if the
Machine.config file defines different settings than the
ones defined in your Web.config file? The good news is that
the settings in the Web.config file override the settings
in the Machine.config file.
There can be more than one web.config file .
Is This Answer Correct ? | 31 Yes | 5 No |
Answer / 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 |
Answer / manikumar
* Configuration information is stored in XML-based text
files. You can use any standard text editor or XML parser to
create and edit ASP.NET configuration files.
* Multiple configuration files, all named Web.config,
can appear in multiple directories on an ASP.NET Web
application server. Each Web.config file applies
configuration settings to its own directory and all child
directories below it. Configuration files in child
directories can supply configuration information in addition
to that inherited from parent directories, and the child
directory configuration settings can override or modify
settings defined in parent directories. The root
configuration file named
systemroot\Microsoft.NET\Framework\versionNumber\CONFIG\Machine.config
provides ASP.NET configuration settings for the entire Web
server.
* At run time, ASP.NET uses the configuration
information provided by the Web.config files in a
hierarchical virtual directory structure to compute a
collection of configuration settings for each unique URL
resource. The resulting configuration settings are then
cached for all subsequent requests to a resource. Note that
inheritance is defined by the incoming request path (the
URL), not the file system paths to the resources on disk
(the physical paths).
* ASP.NET detects changes to configuration files and
automatically applies new configuration settings to Web
resources affected by the changes. The server does not have
to be rebooted for the changes to take effect. Hierarchical
configuration settings are automatically recalculated and
recached whenever a configuration file in the hierarchy is
changed. The <processModel> section is an exception.
* The ASP.NET configuration system is extensible. You
can define new configuration parameters and write
configuration section handlers to process them.
* ASP.NET help protect configuration files from outside
access by configuring Internet Information Services (IIS) to
prevent direct browser access to configuration files. HTTP
access error 403 (forbidden) is returned to any browser
attempting to request a configuration file directly.
In This Section
Is This Answer Correct ? | 9 Yes | 4 No |
Answer / rajitha
"any number of web.config files" can be allowed to use in an
application in .net.
Is This Answer Correct ? | 3 Yes | 0 No |
what is the difference b/w Asp.net server controls and html server controls in .net?
2 Answers iGate, Profiniti Systems,
Which platform does Microsoft .NET use for exchanging data between applications?
can any one explain about 3-tier architecture and how to deploy 3 layers of 3-tier architecture in 3 different servers.plz send me .net code
What is owin authentication?
How to rename a table using sql queries?
What is ashx file in asp.net?
Can you explain what inheritance is and an example of when you might use it?
About duration in caching technique ?
how many script manager controls are used in Ajax web page?
7 Answers CSC, Health Prime Services, TCS,
Is viewstate enabled by default?
What is difference between or and orelse?
What is the difference between c# and .net?