在 HttpWebRequest 中添加自定义标头 [英] Add custom header in HttpWebRequest
本文介绍了在 HttpWebRequest 中添加自定义标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要向 HttpWebRequest
对象添加一些自定义标头.如何将自定义标头添加到 Windows Phone 7 中的 HttpWebRequest
对象.
I need to add some custom headers to the HttpWebRequest
object. How can I add Custom Header to HttpWebRequest
object in Windows Phone 7.
推荐答案
您使用带有字符串索引的 Headers
属性:
You use the Headers
property with a string index:
request.Headers["X-My-Custom-Header"] = "the-value";
根据 MSDN 的说法,此功能自以下开始可用:
According to MSDN, this has been available since:
- 通用 Windows 平台 4.5
- .NET 框架 1.1
- 便携式类库
- 银光 2.0
- Windows Phone Silverlight 7.0
- Windows Phone 8.1
https://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.headers(v=vs.110).aspx
这篇关于在 HttpWebRequest 中添加自定义标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文