As you saw .Net Fx does not allow editing the host header, but with .Net Fx 4.0 there is a separate definition for "Host" in the HttpWebRequest object. You can use it as follows:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://127.0.0.1/");
request.Host = "yourdomain.com";
Hope this helps you.
source
share