PassionateDeveloper
PassionateDeveloper

Reputation: 15138

Add "Host" to the Headers, getting an error (HTTPWebRequest)

I must use this:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Headers.Add("Host", "gs.apple.com");
response = request.GetResponse();

But I get an error. "This header must be modified using the appropriate property."

I googled a lot and found, that I should use a property or the HTTPWebRequest. But there is no Host-Property.

I need to manipulate it, how I can do it?

(C#.Net)

Upvotes: 0

Views: 11298

Answers (1)

Eugene Cheverda
Eugene Cheverda

Reputation: 8930

MSDN says:

Host

Set by the system to current host information.

If you want to modify it try:

request.Headers["Host"] = "gs.apple.com";

or

request.Host = "gs.apple.com";

The appropriate property is HttpWebRequest.Host

Link

Upvotes: 2

Related Questions