Returning JSON from WCF Web API
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.
精彩评论