Debug a Generic IIS internal server error on an Azure Web App in 5 minutes

Have you come across this unhelpful IIS server error? Perhaps when making a .NET Web release to an Azure Web App for the first time?

Usually this occurs because something is not set correctly in the Web.Config. Such as an element missing a rogue chevron > or in my case a duplicate httpCookies element. In this post I will show how you can very quickly figure out what is causing the error.

First turn on Application Logging and Detailed error messages for the affected Web App by scrolling down to App Service Logs and turn on the settings, make sure your level is set to Error:

This will enable Application logging and start writing to log files into D:\home\LogFiles\Application. However we will be using the Log Stream to view our error message instead of digging into the file system.

To view our Application Log, just below App Service logs click Log stream. Give it a moment to warm up and then attempt to refresh the page of the affected site. Make sure you are viewing the Application logs and not the Web Server logs. It should start to stream in the html of the error page.

Note: the screenshot contains a different error and is shown for instructional purposes. In this case a rogue chevron has made it into the web.config

Highlight, copy the html and paste it into an editor such as VSCode. Then apply some formatting to make it easier to read or save it as a html file and open it in your browser.

 

Looks like I have two httpCookies elements in my Web.Config. Opening the App Service Editor I can see that there are indeed two httpCookies elements set. I found these were introduced by the Web.Release.Config transform during deployment.

After removing the duplicate element, the site now loads.

Published on: Sunday, October 25, 2020

Last updated: Tuesday, December 22, 2020

Posts you may like