Disable JSON Support in ASP.NET MVC Web API

后端 未结 2 1682
天命终不由人
天命终不由人 2021-01-26 15:39

In the creation of our new MVC Web API-based service, we want to focus on XML to begin with and add JSON functionality later as an enhancement, using the full release with nativ

2条回答
  •  庸人自扰
    2021-01-26 16:21

    There's an even shorter option, because there can be only one Json formatter and the MediaTypeFormatterCollection exposes it as a property. Available since Web API 2 (maybe also in v1, not sure).

    Formatters.Remove(controllerSettings.Formatters.JsonFormatter)

提交回复
热议问题