When is web.config read?

2020-02-29 05:01发布

问题:

I'm doing research for an article on the ASP.NET Pipeline, but none of the resources I've covered so far adequately explain when the machine level, and application level, and possibly even sub-application level, web.config files are read.

Also, most of my reading has mislead me to look for default HTTP handlers etc. in machine.config, which seems to, at some point, have been mysteriously replaced by a web.config at the machine level, i.e. in the same config framework folder as machine.config. Are that many articles etc. so out of date, or was this a very recent change? Or, may I be imaginative and consider that the machine level web.config actually 'inherits' from machine.config?

回答1:

The most comprehensive description of how asp.net configration files work that I know of is this one at MSDN:

ASP.NET Configuration File Hierarchy and Inheritance

It is written for the .NET 3.5 framework so the info should be as current as you'll likely find. It describes exactly how the various configuration files are read and merged into the runtime settings for the application in quite a lot of detail.



回答2:

ASP.NET config files work in a hierarchical manner (much the same way as CSS elements).

Configuration Inheritance