We have a utility that automatically sets up ASP.NET web applications upon install on customer servers. This utility traditionally adds a number of configurations to the Location path for the new app in applicationHost.config. We do this programmatically using the Microsoft.Web.Administration configuration classes.
This works fine in IIS 7.0 and IIS 7.5, but when we try to install the identical configuration in IIS 8 (Server 2012), we start getting 500.19 server errors for everything hosted on the server because of a supposedly malformed XML element (HRESULT 0x8007000d). I systematically went through all of the configuration we install, and it appears to be the the system.web/httpRuntime maxRequestLength attribute (see below). It appears that the system.web configuration element itself is the culprit, as the error does not disappear until it itself is removed.
I've confirmed that the section definition for system.web/httpRuntime states that it is allowed Everywhere, and you can set system.web configuration at other levels of the configuration (e.g., web.config) without issue. Why can't we set it in applicationHost.config?
<location path="Default Web Site/ManagementConsole">
<!-- ... more config ... -->
<system.web>
<httpRuntime maxRequestLength="10240" />
</system.web>
</location>
Edit: I noticed after the original post that the file the 500.19 error referenced was a temporary app pool config file (C:\inetpub\temp\apppools\apppoolname\apppoolname.config. The content of that file is:
<!-- ERROR: There's been an error reading or processing the applicationhost.config file. Line number: 905 Error message: The configuration section 'system.web' cannot be read because it is missing a section declaration
-->
But when I go into applicationHost.config and add a section group definition for system.web and a section definition for httpRuntime, the message in the 500.19 changes to claiming that there is a duplicate system.web/httpRuntime definition! So I can't define it, and I can't not define it. What??
I've seen this error occur when all of the necessary modules are not installed. Instead of telling you that a module is missing it will complain that the config is corrupt. Check that the same modules you've installed on the IIS 7/7.5 machines are also installed on IIS 8.