The error may happen in Azure cloud service and other IIS based hosts, here is a case:
Web server returns
“HTTP Error 500.19 – Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.”
Quick troubleshooting way is to remote access the server and try to access the site by local URI, then error will come with details as below:
This error message indicated that the serverRuntime section was locked in parent level, that blocked customized change in your web.config.
By default, system.webServer/serverRuntime is locked, and application can not directly override it in web.config if that is not unlocked in parent level.
To fix the problem in Azure cloud service, a startup task is required in web role project to execute command to unlock the section before the web role is initialized.
Here is the command line:
%systemroot%\system32\inetsrv\APPCMD unlock config /section:system.webServer/serverRuntime
Make sure that the startup task for this command line should be executed as “elevated” and the tasktype is better to be “foreground”.
<Task commandLine=”Startup.cmd” executionContext=”elevated” taskType=”foreground”>
More tips on using startup task in Azure: