.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> ASP.Net >> Post New Question Subscribe to Interview Questions

What is the difference between Machine.config and web.config?

Posted By :Vijay     Posted Date :January 21, 2011    Points :15   Category :ASP.Net 
The main difference between Machine.config and web.config is as follows:
Machine.config is machine level config file,means if you make any changes into this file, it will applicable for all application which exists on same machine.

While Web.config settings only applicable for application level.This file is best place to keep your connection string and SMTP like settings and so on.

You can also find related Interview Question to What is the difference between Machine.config and web.config?  below: 

What is the difference between "Web.config" and "Machine.Config" ?

  
Configuration files are used to control and manage the behavior of a web application.
1. Machine.config
2. Web.config

Machine.Config

One Machine.config file is shared for all ASP.NET's Application. It is only one on the machine for each version of .NET Framework. If you apply anything in machine.config file then it is applied on all ASP.NET applications. Machine.config file is universal on the machine. It can be located in the %runtime install path%\Config directory.

1. This is automatically installed when you install .NET Framework or Visual Studio. Net.
2. This is also called machine level configuration file.
3. Only one machine.config file exists on a server/computer.
4. This file is at the highest level in the configuration hierarchy

Web.Config
Web.config file is only for particular ASP.NET application. each ASP.NET application has different file. One ASP.NET application can have more than one web.config file. But only one in one folder.

1. This is automatically created when you create an ASP.Net web application project.
2. This is also called application level configuration file or folder level configuration file.
3. This file inherits setting from the machine.config. If same setting key is defined in both Machine.Config and Web.config, the Web.Config setting is used.

Difference Between Machine.config and Web.config

Machine.config is automatically installed when you install .NET Framework or Visual Studio. Net.

Web.config is automatically created when you create an ASP.Net web application project.

Machine.config is called machine level configuration file. Only one machine.config file exists on a server.

Web.config is called application level configuration file.

Machine.config file is at the highest level in the configuration hierarchy.

Web.Config file inherits setting from the machine.config (More...)

Difference Between Machine.config and Web.config?

  
Machine.config->Configuration file for all the applications in the system.
Web.config->Config file for single application. (More...)

Difference between "Web.config" and "Machine.Config" ?

  
"Web.config" applies settings to each web application, while "Machine.config" applies settings to all ASP.NET applications. (More...)

What is the difference between machine.config and web.config?

  
With every CLR(Common Language Runtime) of the .Net framework a machine.config file is there. This machine.config file is automatically installed with the .Net framework.

"machine.config", as its name suggests, it provides machine level configuration for the entire machine on which this machine.config file is installed with the .net framework, so it is also called machine level configuration file.

And since it provides setting for the entire machine, so there should be ONLY one machine.config file on a particular machine(computer/server).

This machine.config file is at the highest level in the configuration hierarchy, means, the .net framework will first check the configuration written with the machine.config file, then .net framework can look for any other configuration file.

There is also a web.config file which is also get installed with the .net framework, automatically.

In case of ASP.Net, a web.config file is also there with each Web Application. So when an ASP.Net website is running on a server, its settings will be the combination of the settings mentioned in machine.config file on that particular server, on which this website is running + the settings mentioned with the web.config file of that same server + the settings mentioned with the web.config file of the website's own, which is available into the website's own root directory. (More...)

What is Machine.config?

  
Machine configuration file: The machine. config file contains settings that apply to the entire computer. This file is located in the %runtime install path%Config directory. There is only one
machine. config file on a computer. The Machine.Config file found in the "CONFIG" subfolder of your .NET Framework install directory (c:WINNTMicrosoft.NETFramework{Version Number}CONFIG on Windows 2000 installations). The machine.config, which can be found in the directory $WINDIR$Microsoft.NETFrameworkv1.0.3705CONFIG, is an XML-formatted configuration file that specifies configuration options for the machine. This file contains, among many other XML elements, a browserCaps element. Inside this element are a number of other elements that specify parse rules for the various User-Agents, and what properties each of these parsings supports. (More...)

Is it possible to add multiple Machine.config file?

  
No, it is not possible to add more than 1 machine.config file. if we want to overwrite any setting than that can be achieve with the help of web.config. (More...)

Web.Config vs Machine.config

  
Web.Config Files - It is used to maintain the all type of
configuration like that Database connection and Error log
configuration and also maintain the Authenticate of user
security of the web application

Machine.config - only one file was created in your
microsoft .net folder when you installed the microsoft
visual studio.
So, it is used to configuration for the particular server
machine. (More...)

Why this Error comes during compilation of our ASP page ?

Parser Error Message: It is an error to use a section registered as allowDefinition='MachineOnly' beyond machine.config.

  
This happens because ,

In our web.config file we might have declared a section that is not configurable on our shared web hosting platform. So when we get this error we have to remove that part which is not supported in the web.config file. (More...)

Difference Between Web.Config file and Global.asax ?

  
Web.Config file is used ....

1. To specify the application settings
2. To specify the session mechanism available to use for that application.
3. To Specify the Connection strings.
4. To Specify the authentication and authorization.
5. To Specify the http handlers.
6. To Specify different providers.

Global.asax file is used to specify the session and application event handlers.
(More...)

Difference between web.config and app.config?

  
web.Config -- used in Web Application
app.config -- used in Windows application (More...)

machine.config is available with ASP.Net website?

  
Actually, it is not available with ASP.Net website's own directory/folder, but on which machine/computer, it is being developed Or on which web server, it is running; a machine.config file is there and this machine.config file's setting has a strong impact on the setting of that ASP.Net website. (More...)

What is the difference between web.config and global.asax?

  
web.config:- It is a xml based file.
glbal.asax:- It is class file.

web.config:- It carries configuration data of the ASP.Net website.
global.asax:- It carries application events of the ASP.Net website.

web.config:- If there will be any change made on this file, we need to just save the new file with the ASP.Net website.
global.asax:- If there will be any change made on this file, we need to compile/rebuild the ASP.Net website. (More...)

what is the use of using web.config file

  
By using this web.config file we can store sqlconnection string.This SqlConnection String can be accessed any where in your application.for security purpose of connection string also we can use web.config. (More...)

How you will write a Connection String in web.Config fiel?

  
Ans) Then write below lines of code:

configuration>
connectionStrings>
add name="sqlconnectionstring" connectionString="Data Source=INTHIYAAZ;Initial Catalog=DB;User ID=sa;Password=sa" />
/connectionStrings>
/configuration>
(More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend