Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Core disable json patch

As stated in this article: adding NewtonsoftJson to the application now enables json patch support. I'm wondering how to add NewthonsoftJson without enabling json patch?

like image 700
Grigoryants Artem Avatar asked Jan 24 '26 12:01

Grigoryants Artem


1 Answers

JsonPatch support is handled through the NewtonsoftJsonPatchInputFormatter type. If you don't want this to be enabled, remove it from the InputFormatters collection. Here's an example:

services.AddControllers()
    .AddNewtonsoftJson()
    .AddMvcOptions(o => o.InputFormatters.RemoveType<NewtonsoftJsonPatchInputFormatter>());
like image 64
Kirk Larkin Avatar answered Jan 27 '26 02:01

Kirk Larkin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!