views:

541

answers:

1

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?

+1  A: 

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

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

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

Hope this helps.

feroze
I've seen that page although there are lots of problems in that workaround beside of that it's a really dirty workaround :)
dr. evil
Shame I don't use .NET 4 that looks good.
dr. evil