CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.




Get it now !!
Send your Resume to 6000 Companies

Search Interview Questions

Question: What is Web.config?

Answer: In classic ASP all Web site related information was stored in the metadata of IIS. This had the disadvantage that remote Web developers couldn't easily make Web-site configuration changes. For example, if you want to add a custom 404 error page, a setting needs to be made through the IIS admin tool, and you're Web host will likely
charge you a flat fee to do this for you. With ASP.NET, however, these settings are moved into an XML-formatted text file (Web.config) that resides in the Web site's root directory. Through Web.config you can specify settings like custom 404 error pages, authentication and authorization settings for the Web sitempilation options for the ASP.NET Web pages, if tracing should be enabled, etc.
The Web.config file is an XML-formatted file. At the root level is the <configuration> tag. Inside this tag you can add a number of other tags, the most common and useful one being the system.web tag, where you will specify most of the Web site configuration parameters. However, to specify application-wide settings you use the
<appSettings> tag.
For example, if we wanted to add a database connection string parameter we could have a Web.config file like so:
<configuration>
<!-- application specific settings -->
<appSettings>
<add key="connString" value="connection string" />
</appSettings>
<system.web>
...
</system.web>
</configuration>
Now, in any of your ASP.NET Web pages in this Web site you can read the value of the connString parameter like so:
ConfigurationSettings.AppSettings("connString")
To avoid this complication you can "group" your application's settings into a unique tag in the Web.config file. That is, you can create a tag named: <MyAppSettings> in Web.config and then use the as we did earlier to add application-wide settings. To add a custom tag to Web.config you need to first explicitly specify the new tag name in Web.config via the <configSections> tag, like so:
<configuration>
<configSections>
<section name="MyAppSettings"
type="System.Configuration.NameValueFileSectionHandler,
System, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
</configSections>
...
</configuration>
This <section ... /> tag indicates that we are going to be adding a custom tag named MyAppSettings. Now we can add a <MyAppSettings> tag to our Web.config file and
add <add ... /> tags to add application-wide parameters, like so:
<configuration>
<configSections>
<section name="MyAppSettings"
type="System.Configuration.NameValueFileSectionHandler,
System, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
</configSections>
<MyAppSettings>
<add key="connString" value="connection string" />
</MyAppSettings>
...
</configuration>
To read this custom value from an ASP.NET Web page we use the following syntax:
ConfigurationSettings.GetConfig("MyAppSettings")("connString")



Category DotNet Interview Questions & Answers - Exam Mode / Learning Mode
Rating (0.7) By 532 users
Added on 10/24/2009
Views 9701
Rate it!
Question: What is Web.config?
Answer:

In classic ASP all Web site related information was stored in the metadata of IIS. This had the disadvantage that remote Web developers couldn't easily make Web-site configuration changes. For example, if you want to add a custom 404 error page, a setting needs to be made through the IIS admin tool, and you're Web host will likely
charge you a flat fee to do this for you. With ASP.NET, however, these settings are moved into an XML-formatted text file (Web.config) that resides in the Web site's root directory. Through Web.config you can specify settings like custom 404 error pages, authentication and authorization settings for the Web sitempilation options for the ASP.NET Web pages, if tracing should be enabled, etc.
The Web.config file is an XML-formatted file. At the root level is the <configuration> tag. Inside this tag you can add a number of other tags, the most common and useful one being the system.web tag, where you will specify most of the Web site configuration parameters. However, to specify application-wide settings you use the
<appSettings> tag.
For example, if we wanted to add a database connection string parameter we could have a Web.config file like so:
<configuration>
<!-- application specific settings -->
<appSettings>
<add key="connString" value="connection string" />
</appSettings>
<system.web>
...
</system.web>
</configuration>
Now, in any of your ASP.NET Web pages in this Web site you can read the value of the connString parameter like so:
ConfigurationSettings.AppSettings("connString")
To avoid this complication you can "group" your application's settings into a unique tag in the Web.config file. That is, you can create a tag named: <MyAppSettings> in Web.config and then use the as we did earlier to add application-wide settings. To add a custom tag to Web.config you need to first explicitly specify the new tag name in Web.config via the <configSections> tag, like so:
<configuration>
<configSections>
<section name="MyAppSettings"
type="System.Configuration.NameValueFileSectionHandler,
System, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
</configSections>
...
</configuration>
This <section ... /> tag indicates that we are going to be adding a custom tag named MyAppSettings. Now we can add a <MyAppSettings> tag to our Web.config file and
add <add ... /> tags to add application-wide parameters, like so:
<configuration>
<configSections>
<section name="MyAppSettings"
type="System.Configuration.NameValueFileSectionHandler,
System, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
</configSections>
<MyAppSettings>
<add key="connString" value="connection string" />
</MyAppSettings>
...
</configuration>
To read this custom value from an ASP.NET Web page we use the following syntax:
ConfigurationSettings.GetConfig("MyAppSettings")("connString") Source: CoolInterview.com


Web.con fig file is a collection of settings.
like
database.
session state.
error handling
security.
if u want to do any change we can perform here so it reflect to entire project.

Example:
we develop a project for a company, that company shifted a new place so address is changed. In this time what we do simply changes in web.config file. Source: CoolInterview.com

Answered by: Srikar | Date: 11/16/2009 | Contact Srikar Contact Srikar

Web.config file, as it sounds like is a configuration file for the Asp .net web application. An Asp .net application has one web.config file which keeps the configurations required for the corresponding application. Web.config file is written in XML with specific tags having specific meanings Source: CoolInterview.com

Answered by: sreenivaas varma bolisetty | Date: 1/5/2010 | Contact sreenivaas varma bolisetty Contact sreenivaas varma bolisetty

Web.config file is a collection of settings.
like
database.
session state.
connection string relted info
if u want to do any change we can perform here so it reflect to entire project.

Example:
we develop a project for a company, that company shifted a new place where we have a different p.c.that time what we do simply change the connectin string reside in web,cofig file.. Source: CoolInterview.com

Answered by: himanshu | Date: 5/24/2010 | Contact himanshu Contact himanshu

?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 systemrootMicrosoft.NETFrameworkversionNumberCONFIGMachine.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. Source: CoolInterview.com

Answered by: Rajesh Puhazhendhi | Date: 7/9/2010 | Contact Rajesh Puhazhendhi Contact Rajesh Puhazhendhi

?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 Source: CoolInterview.com

Answered by: venkataramana | Date: 7/22/2010 | Contact venkataramana Contact venkataramana


If you have the better answer, then send it to us. We will display your answer after the approval

Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.

Post your answer here

Inform me about updated answers to this question.
Related Questions
View Answer
What is Machine.config?
View Answer
Using COM Component in .Net
View Answer
Using ActiveX Control in .Net
View Answer
Differences between Datagrid, Datalist and Repeater?
View Answer
Advantages of VB.NET
View Answer
Advantages of migrating to VB.NET
View Answer
Observations between VB.NET and VC#.NET
View Answer

Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

View All DotNet Interview Questions & Answers - Exam Mode / Learning Mode




India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
Cache = 1.21875 Seconds