dotnet / AspNetCore.Docs

Documentation for ASP.NET Core
https://docs.microsoft.com/aspnet/core
Creative Commons Attribution 4.0 International
12.63k stars 25.3k forks source link

Doesn't tell us how to replace JsonOutputFormatter with System.Text.Json alternatives to modify the outputted json for all responses #16637

Open JohnGalt1717 opened 4 years ago

JohnGalt1717 commented 4 years ago

In the past you could inherit from JsonOutputFormatter and override the response. This was useful so that you could have a fully formatted body that wasn't just the json object (which has security issues) and add additional properties like errors etc. to the response.

I don't see anywhere in the documentation information on how you'd replicate this same behavior without having to customize every response on every endpoint.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Rick-Anderson commented 4 years ago

@JamesNK can you outline the approach or for this case should you continue with JsonOutputFormatter?

JohnGalt1717 commented 4 years ago

(Can't continue with JsonOutputFormatter because it uses NewtonsoftJson)