dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.46k stars 10.03k forks source link

MVC actions returning Problem Details should return the standard media type for Problem Details responses #36560

Closed DamianEdwards closed 3 years ago

DamianEdwards commented 3 years ago

MVC actions that return the result of calling ControllerBase.ValidationProblem get a response media type of application/validationproblem+json which is not compliant with the RFC7807 spec that they're based on. The media type should be application/problem+json.

We should be using the standard media type. Given this has been the behavior of MVC since the feature was introduced in 2.x, we might want to consider mitigations to address potential compatibility issues, e.g. an option to configure the media type, the ability to set the media type at the time of generating the response, etc.

DamianEdwards commented 3 years ago

I think we should just fix this in .NET 6 given we're just completely out of spec here. We can add an app context switch for back-compat opt-in if we're concerned about it breaking folks.

mkArtakMSFT commented 3 years ago

Cleaning up the milestone so that you can see this during triage. From what I understand you wanted to fix this for RC2. @rafikiassumani-msft

rafikiassumani-msft commented 3 years ago

We have a similar issue in Minimal. Working with the team to see if we need to fix this as well for Minimal to be consistent with MVC.

DamianEdwards commented 3 years ago

@rafikiassumani-msft see #36557