title: Using a proxy with .NET 4.5 HttpClient
body: <p>I'm troubleshooting a bug with a service I call through .NET's HttpClient, trying to route the request through a local proxy (Fiddler), but my proxy settings seem to not be taking effect.</p>
  
  <p>Here's how I create the client:</p>
  
  <pre><code>private HttpClient CreateHttpClient(CommandContext ctx, string sid) {
      var cookies = new CookieContainer();
  
      var handler = new HttpClientHandler {
          CookieContainer = cookies,
          UseCookies = true,
          UseDefaultCredentials = false,
          Proxy = new WebProxy("http://localhost:8888", false, new string[]{}),
          UseProxy = true,
      };
  
      // snip out some irrelevant setting of authentication cookies
  
      var client = new HttpClient(handler) {
          BaseAddress = _prefServerBaseUrl,
      };
  
      client.DefaultRequestHeaders.Accept.Add(
          new MediaTypeWithQualityHeaderValue("application/json"));
  
      return client;
  }
  </code></pre>
  
  <p>then I send the request by:</p>
  
  <pre><code>var response = CreateHttpClient(ctx, sid).PostAsJsonAsync("api/prefs/", smp).Result;
  </code></pre>
  
  <p>Request goes straight to the server without attempting to hit the proxy.  What did I miss?</p>