title: How to change hostname (host http header) with HttpClient
body: <p>Quick question: is there a way to change the host name that is sent by HttpClient while maintaining the destination url? For instance, in Postman I can create a new custom request that targets site a.com with the host http header set to b.com. I've tried using the following code to achieve that with HttpClient:</p>
  <pre><code>var handler = new HttpClientHandler
                {
                    ServerCertificateCustomValidationCallback = (sender,
                                                                 cert,
                                                                 chain,
                                                                 sslPolicyErrors) =&gt;true
                };
  var httpClient = new HttpClient(handler);
  httpClient.DefaultRequestHeaders.Host = &quot;b.com&quot;;
  
  try
  {
      var uri =
          &quot;https:a.com/someurl/more&quot;;
      var response = await httpClient.GetStringAsync(uri);
      Console.Write(response.Substring(0, 100));
  }
  catch(Exception ex)
  {
      Console.WriteLine(ex);
  }
  </code></pre>
  <p>As it's been pointed out in the comments, I was being redirected to the wrong url becuase Fiddler was active. Now, I must be doing something wrong because the request sent from postman with the custom header does return the correct HTML and the one using HttpClient is giving me a 503.</p>
  <p>Thanks.</p>