Skip to content
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

ReturnHttpNotAcceptable=true Does Not Return ProblemDetails #16889

Open
Tracked by #1413
RehanSaeed opened this issue Nov 7, 2019 · 4 comments
Open
Tracked by #1413

ReturnHttpNotAcceptable=true Does Not Return ProblemDetails #16889

RehanSaeed opened this issue Nov 7, 2019 · 4 comments
Labels
affected-very-few This issue impacts very few customers area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-mvc-execution-pipeline Features related to how MVC executes a controller or razor page severity-minor This label is used by an internal tool
Milestone

Comments

@RehanSaeed
Copy link
Contributor

Describe the bug

Setting MvcOptions.ReturnHttpNotAcceptable to true returns a 406 Not Acceptable status code but the body of the response is empty instead of containing a ProblemDetails object.

To Reproduce

  1. dotnet new webapi
  2. Add this code to Startup.ConfigureServices:
services.AddMvcOptions(x => x.ReturnHttpNotAcceptable = true);
  1. Run curl -i -H "Accept: text/plain" http://localhost:5000/weatherforecast and note that there is no response body.

Further technical details

  • ASP.NET Core version: 3.0.100
  • Include the output of dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.0.100
 Commit:    04339c3a26

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19013
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100\

Host (useful for support):
  Version: 3.0.0
  Commit:  7d57652f33

.NET Core SDKs installed:
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.505 [C:\Program Files\dotnet\sdk]
  2.1.801 [C:\Program Files\dotnet\sdk]
  2.1.802 [C:\Program Files\dotnet\sdk]
  2.2.401 [C:\Program Files\dotnet\sdk]
  2.2.402 [C:\Program Files\dotnet\sdk]
  3.0.100 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and it's version

Visual Studio 2019 16.4.0

@javiercn javiercn added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Nov 7, 2019
@javiercn
Copy link
Member

javiercn commented Nov 7, 2019

@RehanSaeed thanks for contacting us.

@pranavkm Can you take a look?

@pranavkm pranavkm removed their assignment Nov 8, 2019
@pranavkm pranavkm added enhancement This issue represents an ask for new feature or an enhancement to an existing one and removed investigate labels Nov 8, 2019
@pranavkm
Copy link
Contributor

pranavkm commented Nov 8, 2019

@pranavkm pranavkm added this to the 5.0.0-preview1 milestone Nov 8, 2019
@ehjelholt
Copy link

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.

@mkArtakMSFT
Copy link
Member

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.

@javiercn javiercn added affected-very-few This issue impacts very few customers severity-minor This label is used by an internal tool labels Oct 9, 2020 — with ASP.NET Core Issue Ranking
@javiercn javiercn added the feature-mvc-execution-pipeline Features related to how MVC executes a controller or razor page label Apr 18, 2021
@pranavkm pranavkm added old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Oct 19, 2021
@captainsafia captainsafia added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates and removed old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels labels Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affected-very-few This issue impacts very few customers area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-mvc-execution-pipeline Features related to how MVC executes a controller or razor page severity-minor This label is used by an internal tool
Projects
None yet
Development

No branches or pull requests

6 participants