I am using an HttpWebRequest and passing in an Address which is an IP. I then set the host to a garbage value. When I call GetResponse() I am getting an OK even though I would expect this to fail since the host is garbage.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(String.Format("http://10.10.10.10/Default.aspx"));
request.Host = "blah.blah.blah";
request.ContentType = "text/xml";
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
if (response.StatusCode == HttpStatusCode.OK) { /*always enters here */ }
}
Why is the response coming back as OK? Shouldn’t the garbage host cause this to fail?
HttpWebRequest.Host Property:
So there is no effect of
.Hostto the general request, you change some additional behavior.