ASP.NET Web API Controller Specific Serializer

前端 未结 5 1944
深忆病人
深忆病人 2020-12-15 23:46

I\'ve a self host Web API with 2 controllers:

  • For controller 1, I need default DataContractSerializer (I\'m exposing EF 5 POCO)
  • For controller 2, I ne
5条回答
  •  执念已碎
    2020-12-16 00:08

    the controllers actions themselves should not be concerned with how the data is serialized. yo should be able to request the data and any format necessary the operation to retrieve the data would be the same.

    by default web api serialized to json objects. however if you set the content type of the request to xml is should return the same result, but formatted as xml instead of json.

提交回复
热议问题