Open RehanSaeed opened 5 years ago
@RehanSaeed thanks for contacting us.
@pranavkm Can you take a look?
Parking this as an enhancement in 5.0. The 406 is returned as part of ObjectResultExecutor
: https://github.com/aspnet/AspNetCore/blob/4c67855ccfb77e4e06087aa7d61f1d4894716af4/src/Mvc/Mvc.Core/src/Infrastructure/ObjectResultExecutor.cs#L150-L154.
I pondered the same problem today. But 406 is supposed to be returned when no response content type/format can be negotiated. So returning a ProblemDetails instance formatted with applications/json would not be kosher either. In my opinion its better for 406 to return nothing.
As for 500 which is mentioned in #4953 I think ProblemDetails is the right choice.
We've moved this issue to the Backlog milestone. This means that it is not going to happen for the coming release. We will reassess the backlog following the current release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources.
Describe the bug
Setting
MvcOptions.ReturnHttpNotAcceptable
totrue
returns a 406 Not Acceptable status code but the body of the response is empty instead of containing aProblemDetails
object.To Reproduce
dotnet new webapi
Startup.ConfigureServices
:curl -i -H "Accept: text/plain" http://localhost:5000/weatherforecast
and note that there is no response body.Further technical details
dotnet --info
Visual Studio 2019 16.4.0