title: Asynchronous HTTP POST in C# 4.0
body: <p>I've used the following code to perform asynchronous HTTP request in C#.</p>
  
  <pre><code>    private static Task GetUrl(string url)
      {
          var request = (HttpWebRequest)WebRequest.Create(url);
          request.UserAgent =
              "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36";
          request.Accept = "text/html";
          return Task
              .Factory
              .FromAsync&lt;WebResponse&gt;(request.BeginGetResponse, request.EndGetResponse, url)
              .ContinueWith(t =&gt;
              {
                  if (t.IsCompleted)
                  {
                      using (var stream = t.Result.GetResponseStream())
                      {
                          using (var reader = new StreamReader(stream))
                          {
                              //Console.WriteLine("-- Successfully downloaded {0} --", t.AsyncState);
                              //Console.WriteLine(reader.ReadToEnd());
                          }
                      }
                  }
                  else if (t.IsFaulted)
                  {
                      Console.WriteLine("There was an error downloading {0} - {1}", t.AsyncState, t.Exception);
                  }
              });
      }
  </code></pre>
  
  <p>However I'm not sure how I should modify the above code to support HTTP post as well. Any help is appreciated!</p>
  
  <p>In particular I'd like to know how I should add BeginGetRequestStream and EndGetRequestStream into the current function...</p>