What’s the order of applying IIS settings from ApplicationHost.config and web.config

configurationiis-7

If I have an IIS setting configured both in ApplicationHost.config and web.config, what value is going to be applied? Is it an ApplicationHost.config value because it is global to all websites or web.config value because it overrides it? And what happens when I haven't configured it in web.config, should it take this setting from ApplicationHost.config?

The particular setting I have to check is:
system.webServer/security/requestFiltering/requestLimits/maxAllowedContentLength

The reason I'm asking is because I'm getting quite strange results when I try to configure those settings from the C# application. Even if I haven't configured it for the website and I have manually set the value in the ApplicationHost.config I'm still getting a default value from web.config

Best Answer

Config files inherit their values as you move down in scope (server -> site -> application), but by default it's only for specific sections. The IIS site has an article on the ApplicationHost.config file as well as configuration delegation.

As an example, there are two different requestFiltering sections within applicationHost.config: one for an FTP server and one for web sites. You can see how the section for web sites (system.webServer) allows the values to be overridden:

<section name="requestFiltering" overrideModeDefault="Allow" />

Whereas the section under system.ftpServer does not.

<section name="requestFiltering" overrideModeDefault="Deny" />

So, onto your question. You should be able to update the Web.config to modify the allowed content length for your site (and sub-sites), unless you have changed the overrideModeDefault value in your applicationHost.config.