1
Answer

Set http request host header

Erik Juhlin

Erik Juhlin

16y
11.5k
1

Hello,

I want to be able to do a http request to an url at a certain IP-address and with a certain host header.
Seems like HttpWebRequest doesn't support this. When I write:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://127.0.0.1/");
request.Headers.Add("Host", "http://www.foo.com/");
...

I get the message: "The 'Host' header cannot be modified directly."

Is there any other way to do this?

Answers (1)