Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show ASP.NET 5 error page in Azure web app

I am getting a 500 Internal Server Error when deploying our ASP.NET 5 web application to an Azure Web App.

enter image description here

How do I get the details and stacktrace for this exception?

I have done the following but with no luck:

  • Using the diagnostics error page on startup:

    app.UseErrorPage();

  • Setting ASPNET_ENV in Azure portal:

Azure Web App app settings

Using DNX beta 6.

like image 510
Dave New Avatar asked Aug 13 '15 15:08

Dave New


People also ask

Is .NET 5 supported in Azure?

As of March 2021, Microsoft announced that Azure Functions are supported running on . NET 5.

How do I check Azure App Service errors?

Log detailed errors To save the error page or failed request tracing for Windows apps in the Azure portal, navigate to your app and select App Service logs. Under Detailed Error Logging or Failed Request Tracing, select On, then select Save. Both types of logs are stored in the App Service file system.

How do I troubleshoot Azure App Service?

To access App Service diagnostics, navigate to your App Service web app or App Service Environment in the Azure portal. In the left navigation, click on Diagnose and solve problems.


2 Answers

In case this helps someone, I've found out that if you're using ASP.NET RC1 and you're using Azure WebApps and add an App setting called Hosting:Environment with a value of development a stack trace for server 500 errors will display.

enter image description here

For this to work the Configure method in the Startup.cs needs to use the Developer Exception page when you're using the Development environment. Eg:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) {     if (env.IsDevelopment())     {         app.UseDeveloperExceptionPage();         app.UseDatabaseErrorPage();     }      // etc } 
like image 74
neodymium Avatar answered Sep 28 '22 07:09

neodymium


According to this post (thanks Muhammad), I should be able to get the runtime error on Azure by editing the server's web.config (quite correct, Celt).

Unfortunately this did not work - no detailed exception.

I did some digging around and found these "DetailedError" logs:

DetailedErrors

This is what they contained:

HTTP Error 500.0 - Internal Server Error

It appears that something may have been going wrong when trying to resolve favicon.ico at D:\home\site\wwwroot\favicon.ico.

There indeed was no favicon at that location. I rectified this, but still the same problem. In fact, I have never had a favicon, and this used to work.

In the end, I deleted the entire Web App in Azure Portal and republished... TADA, it works again.

like image 28
Dave New Avatar answered Sep 28 '22 08:09

Dave New