Saturday, February 5, 2011

.Net Interview Questions -What is the difference between app.config, web.config and machine.config ?

.Net Interview Questions -What is the difference between app.config, web.config and machine.config ?


Answer:
In this .NET Interview question interviewer expects two things. First the importance of configuration and second in which scenarios are the above file applicable. So lets answer the question in two parts.

The importance of config files
==================================================

App.config, web.config and machine.config are files which store configuration
data in XML format. We need configuration data at application level or at machine/server level.

Scenarios in which the above config files are used===================================================

Machine.config file stores configuration information at system level. It can contain configuration information like timeout in ASP.NET application, requestLimit, memoryLimit, and ClientConnectedCheck etc.
Generally we have two kinds of application web application and windows application. Web.config file stores configuration data for web applications and app.config file store configuration information for windows application.
Application level configuration data can be like connection strings,security
etc.

Some connected questions from this question which the interviewer can
ask
================================================================================

Where do you store connection string ?.

How do you encrypt connection string?

How do you read configuration data from web.config or app.config file in .NET ?

Can we have two web.config files for a web application.
Regards,
Read my 40 other .NET Interview questions

1 comment:

Arun Kakkar said...

Sir
Being a novice Dot Net Programmer, Please provide some examples of settings etc which we can do in web.config but not in app.config & vice versa & same for machine.config etc.
I am one of the many readers of your book ".NET Interview Questions".
I like the way you explain things & manage the book contents.
Keep it up, it would be very beneficial book.