0
votes

I've developed a ASP .net core (3.1) application which is successfully running locally, Now I'm trying to publish the web app through Visual Studio 2019, but getting error as:

An error occurred while processing your request.

Development Mode
Swapping to the Development environment displays detailed information about the error that occurred.

The Development environment shouldn't be enabled for deployed applications. It can result in displaying sensitive information from exceptions to end users. For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development and restarting the app.

I've already tried adding value to "ASPNETCORE_ENVIRONMENT": "Production"

I'm using connection string as below:
Data Source=MyDataSource;Initial Catalog=MyDatabase;Integrated Security=True

1

1 Answers

0
votes

What you're seeing is the default ASP.NET Core error page, including the Development Mode message.

You will need to debug to find out what the problem is. One thing you can do is to access the exception that was thrown and the original request path in an error handler controller or page by using IExceptionHandlerPathFeature:

var exceptionHandlerPathFeature = HttpContext.Features.Get<IExceptionHandlerPathFeature>();
if (exceptionHandlerPathFeature?.Error is FileNotFoundException)
{
    ExceptionMessage = "File error thrown";
}
if (exceptionHandlerPathFeature?.Path == "/index")
{
    ExceptionMessage += " from home page";
}

Here's more info on how to Handle errors in ASP.NET Core.

Some pointers based on the information you provided:

  • Is your data source MyDataSource available through the internet (with the name you specified)?
  • Does your data source really provide Integrated Security with an ASP.NET application in Azure?
  • Enable logging (like Application Insights for ASP.NET Core applications) to find the issue