web config and machine config
what is the di开发者_如何学Goffernce b/w webconfig and machine config
Careful. There is a hierarchy of config files:
applicationHost.config
is the top-level IIS config file.
Next is machine.config
, which is the top-level, server-specific config file.
Next is a server-level web.config
file.
Then there is an application-specific web.config
.
Next, there is an optional application.config file.
Finally, there are optional directory-specific web.config
files.
The higher-level files often contain directives that limit what you can configure in the lower level files. The highest-level web.config
, for example, is where server trust levels are configured.
Web.config is specific to an application.
Machine.config applies across all applications on your server.
So, if i have 3 apps on the same server that share connection strings; machine.config is the way to go.
If i have application specific settings (say timeout interval) that vary across apps; put those in web.config
They are two parts of the same system. Microsoft put some magic in .NET so that machine.config and web.config are merged at runtime. Machine.config provides defaults that web.config can override if you so choose.
Machine.config provides a way to hold configuration that is machine specific. So say you have two environments Production and UAT which need to point to different databases. You can put the connectionStrings for Production and UAT in machine.config on the Production and UAT boxes respectively, and all ASP.NET applications on those machines will have access to the appropriate connectionString.
You can read more about .NET configuration files here.
I'd suggest reading up on ASP.NET Configuration Inheritance. There's other configuration layers besides machine.config
and web.config
, and it helps to know all of the different pieces that may be affecting your application.
machine.config
is a global configuration file containing default settings at machine level which could be overridden in web.config
which is specific to a given application.
精彩评论