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:
...
<div class="col">
<div class="status-content">
<h1>401</h1>
<h2 class="text-danger mb-0">
Unauthorized<small class="text-muted">An internal error occurred during your request!</small>
</h2>
<p class="mt-3 mb-4"></p>
<a href="/" class="btn btn-primary">Go to the homepage</a>
<a href="javascript:history.back()"
class="mt-4 mb-1 d-block"><i class="fa fa-long-arrow-left"></i> Go back</a>
</div>
</div>
...
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)
-
0
Hello BassaSolutions,
could you please provide steps to reproduce.
Regards,
-
0
- Load startup template
- Call any authorized endpoint with postman (without authorization). Add header: X-Requested-With :XMLHttpRequest
- Response content is HTML (target: JSON)
-
0
Hello BassaSolutions,
Please check this similar issue https://support.abp.io/QA/Questions/3281/Swagger-Authorisation--401-Response-instead-of-login-page-redirect#
Regards,