如何设置自定义"主机"在HttpWebRequest的头? [英] How to set custom "Host" header in HttpWebRequest?

查看:157
本文介绍了如何设置自定义"主机"在HttpWebRequest的头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置在HttpWebRequest的自定义主机头?我知道,通常此类不允许你这样做,但反正是有使用反射或类似的东西没有实际需要我用的TcpClient送全包?

How can I set a custom Host header in HttpWebRequest? I know that normally this class doesn't allow you to do so but is there anyway to use reflection or something like that without actually need me to send the whole packet with TCPClient?

推荐答案

有一种迂回的方式来做到这一点,如下所述:

There is a roundabout way to do this, as described here:

http://blogs.msdn.com/ feroze_daud /存档/ 2005/03/31 / 404328.aspx

不过,未来版本的框架(.NET Framework 4.0中)将使它更容易。

However, the next version of the framework (.NET Framework 4.0) will make it easier.

http://blogs.msdn.com/ncl/archive/2009/07/20/new-ncl-features-in-net-4-0-beta-2.aspx

希望这有助于。

这篇关于如何设置自定义"主机"在HttpWebRequest的头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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