Solving the IIS error 500.19 when deploying ASP.NET web applications for the first time to a blank Windows Server 2016 machine

Posted: (EET/GMT+2)

 

You've just installed a fresh, new Windows Server 2016 box, and you want to deploy your shiny new ASP.NET web application onto IIS. You've configured IIS, installed the roles, and copied your application files to the server. Then, you'll launch the browser just to see the following error:

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

Detailed Error Information:
Module IIS Web Core 
Notification BeginRequest
Handler Not yet determined 
Error Code 0x80070021 

Config Error
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".  

Config File \\?\C:\Web Apps\MyAspNetApp\web.config

How to solve this issues? Sometimes, it's the basics. After installing the IIS role and the web server features, have you enabled and installed application development support on the machine (using Server Manager)? If not, you'll get the above error.

To solve the problem, enabled the features for ASP.NET 4.6 and you should be good to go!