Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between web.config and machine.config?

Tags:

asp.net

iis

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

I have read that:-

The web.config files specify configuration settings for a particular web application, and are located in the application's root directory; the machine.config file specifies configuration settings for all of the websites on the web server, and is located in $WINDOWSDIR$\Microsoft.Net\Framework\Version\Config.

Is there anything which I am missing or any other technical aspect? I want to know more about both the files.

like image 484
Rahul Tripathi Avatar asked Sep 21 '12 16:09

Rahul Tripathi


People also ask

What is web config used for?

A web. config file is a Windows file that lets you customize the way your site or a specific directory on your site behaves. For example, if you place a web. config file in your root directory, it will affect your entire site (www.coolexample.com).

Where is the machine web config?

The machine. config file is stored in the %WINDIR%\Microsoft.NET\Framework folder in the directory where Microsoft Windows is installed. By default, it is located in the following path: C:\WINDOWS\Microsoft.NET\Framework\v1. 1.4322\CONFIG.

Is app config and web config are same?

You can have a web. config for each folder under your web application. app. config is used for windows applications.

Can we have 2 web config files?

Yes you can have two web. config files in application. There are situations where your application is divided in to modules and for every module you need separate configuration. For example if you have a application which has two modules lets say accounts and sales.


1 Answers

Each CLR version has a machine.config file, along with an additional web.config file, which I refer to as the "machine level web.config file".

Additionally, as you note, each web application also has a web.config file. Directories inside a web application can also have web.config files too.

Now, the key point is that config files inherit from each other. That means, a web application will read settings defined in the machine.config file and the machine level web.config file (for its given framework version), and its own web.config file.

A common use case for defining things in the machine.config would be to share values between many applications on the server, like a connection string perhaps, or SMTP server settings, things like that.

like image 65
wsanville Avatar answered Oct 06 '22 13:10

wsanville