Open Closed

How to get a JSON response on 401 / Unauthorized #5983


User avatar
0
BassaSolutions created
  • ABP Framework version: v6.0.3

  • UI type: Blazor

  • DB provider: EF Core

  • Tiered (MVC) or Identity Server Separated (Angular): no

When sending X-Requested-With :XMLHttpRequest in the header, the correct status is responded when unauthorized: 401 instead of 200.

But the content is still the HTML page:

...

401

UnauthorizedAn internal error occurred during your request!

Go to the homepage Go back
...

How can I get a the default error JSON response content?

{
  "error": {
    "message": "Some error message"
  }
}

I tried to send additional headers:
Content-Type: application/json
Accept: application/json

But the content is always HTML.

Thank you for your help!


3 Answer(s)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.3.0-preview. Updated on April 11, 2025, 10:10