更改 HttpWebRequest 的 HTTP 版本 (C#)
我知道这可能是一个非常基本的问题。
Windows Azure 需要我使用 HTTP 1.1
来调用他们的 REST API 方法。但是,当我调用我的方法时,我从它们那里得到以下响应:
<?xml version="1.0" encoding="utf-8"?><Error><Code>UnsupportedHttpVersion</Code>
<Message>The HTTP version specified is not supported for this operation by the server.
RequestId:7cc39976-f022-4f15-b2a3-733fea600b95 Time:2012-01-12T05:52:44.1107398Z</Message>
<Version>1.0</Version><Via /></Error>
这是 C# 语言,因此我使用的对象是 HttpWebRequest
。我尝试在 http://en.wikipedia.org/wiki/List_of_HTTP_header_fields 中查找标题,但是我没有找到任何有价值的信息。
谁能给我带来光明吗? :)
I understand this might be a very basic question.
Windows Azure needs me to use HTTP 1.1
to call their REST API methods. However, when I call my methods, I get the following response from them:
<?xml version="1.0" encoding="utf-8"?><Error><Code>UnsupportedHttpVersion</Code>
<Message>The HTTP version specified is not supported for this operation by the server.
RequestId:7cc39976-f022-4f15-b2a3-733fea600b95 Time:2012-01-12T05:52:44.1107398Z</Message>
<Version>1.0</Version><Via /></Error>
This is in C#, so the object I am using is a HttpWebRequest
. I have tried looking under headers in http://en.wikipedia.org/wiki/List_of_HTTP_header_fields but I haven't found any valuable information.
Can anyone show me the light? :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HTTP 版本不是 HTTP 标头。要设置 HttpWebRequest 的 HTTP 版本,请使用 HttpWebRequest.ProtocolVersion 属性。
有关说明和示例代码,请阅读 MSDN: HttpWebRequest.ProtocolVersion 属性
Version of HTTP is not an HTTP header. To set HTTP version for
HttpWebRequest
useHttpWebRequest.ProtocolVersion
property.For description and sample code read in MSDN: HttpWebRequest.ProtocolVersion Property