【问题标题】:ASP.NET Core disable json patchASP.NET Core 禁用 json 补丁
【发布时间】:2020-07-02 09:58:01
【问题描述】:

正如article 中所述:将 NewtonsoftJson 添加到应用程序现在启用 json 补丁支持。我想知道如何在不启用 json 补丁的情况下添加 NewthonsoftJson?

【问题讨论】:

    标签: c# asp.net-core json.net asp.net-core-mvc


    【解决方案1】:

    JsonPatch 支持通过 NewtonsoftJsonPatchInputFormatter 类型处理。如果您不希望启用此功能,请将其从 InputFormatters 集合中删除。这是一个例子:

    services.AddControllers()
        .AddNewtonsoftJson()
        .AddMvcOptions(o => o.InputFormatters.RemoveType<NewtonsoftJsonPatchInputFormatter>());
    

    【讨论】:

      猜你喜欢
      • 2018-02-22
      • 1970-01-01
      • 1970-01-01
      • 2021-02-24
      • 1970-01-01
      • 1970-01-01
      • 2015-05-21
      • 2021-12-26
      • 2022-06-14
      相关资源
      最近更新 更多