开发者

Returning JSON from WCF Web API

开发者 https://www.devze.com 2023-04-04 07:44 出处:网络
The WCF Web API returns data either XML or JSON based on the Accept par开发者_运维百科ameter in the request header not considering whether we set ResponseFormat=WebMessageFormat.Json in the WebInvoke/

The WCF Web API returns data either XML or JSON based on the Accept par开发者_运维百科ameter in the request header not considering whether we set ResponseFormat=WebMessageFormat.Json in the WebInvoke/WebGet attributes. Is this the correct behavior of the API or a bug?


WCF Web API ignores the ResponseFormat attribute. That attribute is just there because of an effort to be backward compatible with previous WCF REST efforts. The returned media type is based largely on the Accept header sent by the client.

0

精彩评论

暂无评论...
验证码 换一张
取 消