title: Use WebClient, DownloadData method and Custom Header to Post to a web page
body: <p>** Update I have a solution below, but it's rather manual... if there is an easier way, I'd prefer that answer.</p>
  
  <p>I want to record execution and download time of a webpage, and I am trying to use the WebClient.DownloadDataAsync method to post data to a page and get a result.</p>
  
  <p>I know there are numerous ways to post using WebClient or WebRequest objects, but none of them dispatch the DownloadProgressChanged event. This event is key, as I want to track progress of the download, which is in the area of 30 megs+.</p>
  
  <p>I figure the best way to do this would be to construct the header manually, but I'm hitting a dead-ends. Mainly, I cannot add the data to the request.</p>
  
  <pre><code>WebClient client = new WebClient();
  //!!!!*****no idea how to add the following data to the request
  string data = "test1=value"; 
  client.Headers.Add( "POST", "/About.aspx HTTP/1.1" );
  client.Headers.Add( "Host", "http://localhost:12065" );
  client.Headers.Add( "Content-Type", "application/x-www-form-urlencoded" );
  client.Headers.Add( "Content-length", data.Length.ToString() );
  
  client.DownloadProgressChanged += OnDownloadProgressChanged;
  client.DownloadDataCompleted += OnDownloadDataCompleted;
  client.DownloadDataAsync( new Uri( "http://localhost:12065/About.aspx" ) );
  </code></pre>
  
  <p>I am open to other solutions, or getting the header in this example to work as if the client is sending a POST.</p>