title: Difference between HttpClient PostAsync and SendAsync
body: <p>Working on a project where a WPF front end, and trying to get a handle on async calls to <code>HttpClient</code> and I've been going around and around trying to get <code>PostAsync</code> to work, but it routinely appears to deadlock, or at least the post response times out, even with large values for timeout, and a visible response in fiddler.</p>
  <p>So, after a while I decided to try out a few other methods on HttpClient, and they worked, first try. No idea why.</p>
  <p>I'm clean all the way to my WPF button with <code>awaits</code>, <code>asyncs</code>, and <code>.ConfigureAwait(false)</code> (I think):</p>
  <p>Button:</p>
  <pre><code>private async void Generate_Suite_BTN_Click(object sender, RoutedEventArgs e)
  {
      await suiteBuilder.SendStarWs().ConfigureAwait(false);
  }
  </code></pre>
  <p>XmlDoc Load:</p>
  <pre><code>internal async Task SendStarWs()
  {
      var xmlDoc = new XmlDocument();
      xmlDoc.Load(&quot;C:\\Temp\\file.xml&quot;);
      await StarWSClient.SendStarMessage(xmlDoc).ConfigureAwait(false);
  }
  </code></pre>
  <p>SendMessage:</p>
  <pre><code>private static readonly HttpClient Client = new HttpClient {MaxResponseContentBufferSize = 1000000};
  
  public static async Task&lt;STARResult&gt; SendMessage(vars)
  {
  var response = await SendRequestAsync(url, contentNew, Client).ConfigureAwait(false);
  return new STARResult(response, hash);
  }
  </code></pre>
  <p>This call '500s' against my endpoint immediately, which I'd expect:</p>
  <pre><code>var response = await SendRequestAsync(url, contentNew, Client).ConfigureAwait(false);
  
  private static async Task&lt;HttpResponseMessage&gt; SendRequestAsync(string adaptiveUri, StringContent content, HttpClient httpClient)
  {
      HttpResponseMessage responseMessage = null;
      try
      {
          responseMessage = await httpClient.SendAsync(new HttpRequestMessage(HttpMethod.Post, adaptiveUri)).ConfigureAwait(false);
      }
      catch (Exception ex)
      {
          if (responseMessage == null)
              responseMessage = new HttpResponseMessage
              {
                  StatusCode = HttpStatusCode.InternalServerError,
                  ReasonPhrase = $&quot;SendRequestAsync failed: {ex.Message}&quot;
              };
      }
      return responseMessage;
  }
  </code></pre>
  <p>The Post variant returns a TaskCancellationException, with timeout message regardless of timeout value:</p>
  <pre><code>var response = await PostRequestAsync(url, contentNew, Client).ConfigureAwait(false);
  
  private static async Task&lt;HttpResponseMessage&gt; PostRequestAsync(string adaptiveUri, StringContent content, HttpClient httpClient)
  {
      HttpResponseMessage responseMessage = null;
      try
      {
          responseMessage = await httpClient.PostAsync(adaptiveUri, content).ConfigureAwait(false);
      }
      catch (Exception ex)
      {
          if (responseMessage == null)
              responseMessage = new HttpResponseMessage
              {
                  StatusCode = HttpStatusCode.InternalServerError,
                  ReasonPhrase = $&quot;PostRequestAsync failed: {ex.Message}&quot;
              };
      }
      return responseMessage;
  }
  </code></pre>
  <p>My endpoint responds normally to our other software, so I'm pretty sure the endpoint is solid, I can't fathom why the post response is blocked, when the send isn't.</p>