April 3, 2020 08:04 by
Peter
IIS has ever increasing amounts of security, you can’t publish a basic ASP.NET MVC website anymore and expect IIS 8 to host it without some additional work. The default config settings that the MVC uses are locked down in IIS, so it issues an error when you try to navigate to your fresh site.
Initially you may get a screen that says something bland and non-descriptive, like “Internal Server Error” with no further information. To get the more detailed error messages modify your web application’s web.config file and add the following line to the system.webServer section:
<httpErrors errorMode="Detailed" />
Now, you’ll get a more detailed error message. It will look something like this:
The key to the message is: This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
The “Config Source” section of the error message will highlight in red the part that is denied.
In order to allow the web.config to modify the the identified configuration element you need to find and modify the ApplicationHost.config file. It is located in C:\Windows\System32\inetsrv\config. You’ll need to be running as an Administrator level user in order to modify the file.
Find the section group the setting belongs to, e.g.
<sectionGroup name="system.webServer">
Then the section itself:
<section name="handlers" overrideModeDefault="Deny" />
And update overrideModeDefault to "Allow" in order to allow the web.config to override it.
When you refresh the page for the website the error will be gone (or replaced with an error for the next section that you are not permitted to override)