-1

This ASP.NET Core 3.1 web application that is hosted in Azure App Service is using a serverless version of SQL Server as a database. It is speaking to SQL Server through Entity Framework Core. I am suspecting this error is occurring because the database is taking time to boot up. It disappears after requesting the page a second or third time.

Is there a way to catch this exception in ASP.NET Core and return a more helpful message to the user based on this specific exception?

Screen capture of error:

enter image description here

crayden
  • 2,130
  • 6
  • 36
  • 65
  • 2
    What is the underlying exception? This error is a generic catch-all. – David L Aug 24 '21 at 21:03
  • If your question is only for catching exception message and details in the web app deployed in azure, I think you can enable azure application insights in azure portail->your web app->app insights->choose enable. – Tiny Wang Aug 25 '21 at 01:43
  • Use a retry strategy – ErikEJ Aug 25 '21 at 06:04

1 Answers1

0

The error you have shared is coming from in-built generic catch. ASP.NET use UseExceptionHandler for exception handling that allows us to configure custom error handling route. Please check here.

This is useful when an application runs under production environment. As you are using Development environment, you should set environment variable ASPTNETCORE_ENVIRONMENT=Development. To do so, please visit How to set ASPNETCORE_ENVIRONMENT to be considered for publishing an ASP.NET Core application

To know more about the exception handling in ASP.NET Core 3.1, please visit Handle errors in ASP.NET Core.

Utkarsh Pal
  • 4,079
  • 1
  • 5
  • 14