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

Matthew Hart
3 min readDec 27, 2020

--

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?

The page cannot be displayed because an internal server error has occured

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:

Screenshot of the settings in Azure to turn on Application Logging

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.

A screenshot of the HTML error page that is returned when the error is triggered

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.

A screenshot of the HTML containing the IIS error message opened in VS Code
A screenshot of the IIS Error page HTML opened in a 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.

Duplicated httpCookies element inside the web.config

After removing the duplicate element, the site now loads.

Originally published at https://mattou07.net.

--

--

Matthew Hart
Matthew Hart

Written by Matthew Hart

0 Followers

I work for Moriyama where my main focus is anything DevOps and Umbraco

Responses (1)