0

In the startup.cs code I do the following in the Configure method :

        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

As a result, in my environment is not Development, when calling the API from Postman or even from a dedicated frontend, the error details are not returned.

However the environment variable ASPNETCORE_DETAILEDERRORS is set to true , so I would expect to receive details of the exception.

As a workaround, I had to create my own configuration setting and change the code to :

         if (env.IsDevelopment() || Configuration["DetailedErrors"] == "true")
        {
            app.UseDeveloperExceptionPage();
        }

Do I really need to do that or am I missing something ?

1
  • ASPNETCORE_DETAILEDERRORS only affects startup errors. It doesn't, and isn't intended to, magically enable the developer exception page middleware. Commented Dec 15, 2020 at 14:04

1 Answer 1

1

According to

in my environment is not Development,

I understood that you wish to receive a detailed exception in the production environment.

if this is the case, you may just replace

    if (env.IsDevelopment() || Configuration["DetailedErrors"] == "true")
    {
        app.UseDeveloperExceptionPage();
    }

with

app.UseDeveloperExceptionPage();

Not critical but the if condition became useless I believe so better to get rid of it (as your ASPNETCORE_DETAILEDERRORS variable is set to true).

Sign up to request clarification or add additional context in comments.

1 Comment

I have tried that. Obviously by removing the condition, errors are returned fine. However if I set the ASPNETCORE_DETAILEDERRORS, the errors are STILL returned. I would expect this env variable to have some effect, but it does not seem to change anything.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.