Cloud Service – HTTP Error 500.19

The error may happen in Azure cloud service and other IIS based hosts, here is a case:

• Behavior

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.

• Analysis:

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:

http500er1

More:

http500er2

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.

• Solution:

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:
http://msdn.microsoft.com/en-us/library/windowsazure/gg456327.aspx
http://blogs.msdn.com/b/avkashchauhan/archive/2011/03/17/using-startup-task-in-windows-azure-detailed-summary.aspx

Leave a Reply

Your email address will not be published. Required fields are marked *