为什么OData的网页API返回JSON只 [英] Why OData Web API returns JSON only
问题描述
这是不可思议!我从控制器创建ASP.NET MVC 5.返回IQueriable的OData的Web API,没什么特别的。
This is weird! I create OData Web API with ASP.NET MVC 5. Return IQueriable from the controller, nothing special.
但由于某些原因的当我需要XML 它不断地返回JSON。
But in some reason it constantly returns JSON when I need XML.
我送得到提琴手与接受:应用/ XML - 无反应
I send GET from Fiddler with Accept: application/xml - no reaction.
我试图迫使服务器code删除JsonFormater - 无反应再
I try to force removing JsonFormater in the server code - no reaction again.
它总是返回JSON。我怎么错过?
It always returns JSON. What do I miss?
推荐答案
试着用 - 接受:应用程序/原子+ XML
在AFAIK的OData V3有三个protocals(<一个href=\"http://stackoverflow.com/questions/12015473/web-api-odataresult-is-always-serializing-to-atom\">ref) -
AFAIK in OData V3 there are three protocals (ref) -
- 的Atom(应用程序/原子+ XML)
- 详细JSON(应用/ JSON; ODATA =详细)
- JSON灯(应用/ JSON; ODATA =光)
这篇关于为什么OData的网页API返回JSON只的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!