title: WebClient vs. HttpClient - Async request
body: <p>I have this very simple WebApi method:</p>
  
  <pre><code>[HttpGet]
  public IHttpActionResult Foo()
  {
      Thread.Sleep(3000);
      return Ok("Bar");
  }
  </code></pre>
  
  <p>And I have these two methods in a console application that call it:</p>
  
  <pre><code>async Task UsingWebClient()
  {
      Task&lt;string&gt; task = new WebClient().DownloadStringTaskAsync (new Uri ("http://localhost.fiddler:63710/api/producttype/Foo"));
      Console.WriteLine("WebClient - Before calling wait");
      string result = await task;
      Console.WriteLine("WebClient - After calling wait");
  }
  
  async Task UsingHttpClient()
  {
      Task&lt;string&gt; task = new HttpClient().GetStringAsync (new Uri ("http://localhost.fiddler:63710/api/producttype/Foo"));
      Console.WriteLine("HttpClient - Before calling wait");
      string result = await task;
      Console.WriteLine("HttpClient - After calling wait");
  }
  </code></pre>
  
  <p>And I am calling these methods from LinqPad like this:</p>
  
  <pre><code>async Task Main()
  {
      await UsingWebClient();
      await UsingHttpClient();
  }
  </code></pre>
  
  <p>I was monitoring the traffic using Fiddler and I noticed that:</p>
  
  <ul>
  <li>when using WebClient the request to the web api is made immediately
  and then execution continues to Console.WriteLine("WebClient - Before
  calling wait");</li>
  <li>when using HttpClient the request to the web api is not made until
  the call to await task;</li>
  </ul>
  
  <p>I'm trying to understand why the request is not made immediately when using HttpClient. Can anyone point me in the right direction?</p>
  
  <p>This is not a duplicate question. I'm not looking for reasons to choose one option over the other - I'll use HttpClient. I would like to know specifically why the request is created at a later stage when using HttpClient.</p>
  
  <p>Thanks,
  David</p>