Hellang.Middleware.ProblemDetails does not display detail element after the project is published

Viewed 257

In development environment it is displaying the error as

{
    "type": "https://httpstatuses.com/401",
    "title": "Unauthorized",
    "status": 401,
    "detail": "LOGIN",  -- this is where I send detail of the error
    "errors": [
        {
            error-stack
        } ...

Once published, not only is the errors element missing, even the detail is also missing.

{
    "type": "https://httpstatuses.com/401",
    "title": "Unauthorized",
    "status": 401,
    "traceId": "|b1bda8d6-44744a1efb1ef714."
}

How can I always have the detail element enabled?

1 Answers

hello comment this lines of code in startup.cs

  if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
        }

and just write this line after comment that

 app.UseDeveloperExceptionPage();

now you can see exceptions in real server.

Related