I am getting a 500 Internal Server Error when deploying our ASP.NET 5 web application to an Azure Web App.
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:
Using DNX beta 6.
As of March 2021, Microsoft announced that Azure Functions are supported running on . NET 5.
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.
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.
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.
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 }
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:
This is what they contained:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With