如何向webapi请求特定的内容类型 [英] how to ask webapi for a specific content type

查看:116
本文介绍了如何向webapi请求特定的内容类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它具有内容协商,并且它将返回客户端请求的内容类型

as I understood from ASP.net MVC 4 Release notes, is that it has Content Negotiation, and that it will return the content type requested by the client

客户如何要求特定内容?

(在我的情况下,

推荐答案

就像范西姆克所说,您只需设置所需的内容类型即可。

Like vansimke said, you just set the content type you need.

在ActionScript客户端中,它应该很简单:

In the ActionScript client, it should be as easy as:

request.setHeader("Accept", "application/xml"); 

然后服务器以标题 Content-Type进行响应。

The server then respons with the header "Content-Type".

response.setHeader("Content-Type", "application/xml"); 

希望有帮助!

编辑:标头错误。

这篇关于如何向webapi请求特定的内容类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆