C# Capture HTTP response when the page is fully loaded
<p>I want to send a http post request and capture the response. I have written following code. </p>

<pre><code>System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
   req.Proxy = new System.Net.WebProxy(ProxyString, true);
   //Add these, as we're doing a POST
   req.ContentType = "application/x-www-form-urlencoded";
   req.Method = "POST";
   //We need to count how many bytes we're sending. 
   //Post'ed Faked Forms should be name=value&amp;
   byte [] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
   req.ContentLength = bytes.Length;
   System.IO.Stream os = req.GetRequestStream ();
   os.Write (bytes, 0, bytes.Length); //Push it out there
   os.Close ();
   System.Net.WebResponse resp = req.GetResponse();
   if (resp== null) return null;
   System.IO.StreamReader sr = 
         new System.IO.StreamReader(resp.GetResponseStream());
   return sr.ReadToEnd().Trim();
</code></pre>

<p><strong>Update 1:</strong></p>

<p>I tried making use of PostAsync method. Still the same result.</p>

<pre><code>public static async void Req()
        {
            using (var client = new HttpClient())
            {
                var values = new Dictionary&lt;string, string&gt;
    {
       { "type1", "val1" },
       { "type2", "val2" },
       { "type3", "val3"}
    };
                var content = new FormUrlEncodedContent(values);
                var r1 = await client.PostAsync(URL, content);

                var responseString = await r1.Content.ReadAsStringAsync();
                Console.WriteLine(responseString);
                Console.ReadLine();
            }
        }
</code></pre>

<p>But its capturing only partial response. My Page takes 10-12 seconds to load. How do I make my script wait and capture complete response?</p>