-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Content-Type for BadRequest with ProblemDetails-object #5
Comments
Not really. In the former case, it's actually MVC writing the body. The middleware is never involved. While the latter is just setting the status code and the middleware takes care of writing the body, which is why it has the correct content type. Unfortunately, there's not much I can do about this in this repo, but I can take a stab at sending a PR to MVC to detect A workaround is to specify the content type directly when returning the result from the action. |
That would be great! Thanks for the quick response! |
I've filed aspnet/Mvc#8467. I think that's the best place to track this. If you need a workaround, you should explicitly add the content types: Middleware/src/ProblemDetails/ProblemDetailsMiddleware.cs Lines 157 to 164 in 4ccada4
|
Looks like this will be fixed in ASP.NET Core 2.2 Preview 3; aspnet/Mvc#8512 |
Hi and thanks for your middlware for ProblemDetails! 👍
This is more a question and not an issue (?):
When you return BadRequest with an object that is or derives from ProblemDetails the Content-Type will be application/json.
But when you return BadRequest without any object the Content-Type will be application/problem+json.
Is that by design?
Regards
Niklas
The text was updated successfully, but these errors were encountered: