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



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

Answer / swaroop

We can have number of config files in an application.

Is This Answer Correct ?    96 Yes 12 No

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

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

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

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

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

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

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

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

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

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

Post New Answer

More ASP.NET Interview Questions

How to use DevExpress controls

1 Answers  


What is the function of the CustomValidator? a) It allows for custom C# client-side code to validate entries in a control. b) It allows for a custom mixture of validator controls to use one central control for the display of messages. c) It uses scripted client-side code to validate the entry in a control. d) It uses server-side code to validate the entry in a control.

4 Answers   ABC, Syntax Softtech, TCS,


What is Dynamic Web and discuss its usage with the help of real life examples?

0 Answers   Huawei,


Types of session management in ASP.NET ?

2 Answers   Microsoft,


List the asp.net validation controls?

0 Answers  






What is the file extension of web service?

0 Answers  


where the stored procedure are written in business logic or data acess layer?

2 Answers  


How does the XmlSerializer work? What ACL permissions does a process using it require?

2 Answers  


List the types of authentication supported by asp.net?

0 Answers  


What is form method?

0 Answers  


Please brief not about xsd,xslt & xml?

0 Answers  


Explain the difference between asp.net mvc and asp.net webforms

0 Answers  


Categories