在 POST 方法 Windows Phone 7 中将标头添加到 WebHeaderCollection
我的服务器要求我们将包含设备ID的标头发布到服务器,通常我们可以做这样的事情:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_connectionURL);
request.ContentType = "application/x-www-form-urlencoded";
request.Headers.Add // THIS METHOD DOESN'T EXIST in windows phone 7
request.Method = "POST";
它有这个方法,允许您设置可用的标头,但是我想要的标头不包含在那里,我该怎么办将另一个标头添加到 WebHeaderCollection。
request.Headers.AllKeys.SetValue //this function to set the available headers.
My server requires us to post a header that include device ID to server, normally we can do some thing like this:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_connectionURL);
request.ContentType = "application/x-www-form-urlencoded";
request.Headers.Add // THIS METHOD DOESN'T EXIST in windows phone 7
request.Method = "POST";
It has this method, which allows you to set available headers, but the header I want is not included there, how can I add another header to WebHeaderCollection.
request.Headers.AllKeys.SetValue //this function to set the available headers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有些标头受到限制,例如 Referrer,会抛出异常。
Some headers are restricted, such as Referrer, and will throw an exception.