title: Getting the Response of a Asynchronous HttpWebRequest
body: <p>Im wondering if theres an easy way to get the response of an async httpwebrequest.</p>
  
  <p>I have already seen this question <a href="https://stackoverflow.com/questions/9877120/how-do-i-actually-get-the-response-of-an-async-web-request-from-outside-the-meth">here</a> but all im trying to do is return the response (which is usually json or xml) in the form of a string to another method where i can then parse it/ deal with it accordingly.</p>
  
  <p>Heres some code:</p>
  
  <p>I have these two static methods here which i think are thread safe as all the params are passed in and there are no shared local variables that the methods use?</p>
  
  <pre><code>public static void MakeAsyncRequest(string url, string contentType)
  {
      HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
      request.ContentType = contentType;
      request.Method = WebRequestMethods.Http.Get;
      request.Timeout = 20000;
      request.Proxy = null;
  
      request.BeginGetResponse(new AsyncCallback(ReadCallback), request);
  }
  
  private static void ReadCallback(IAsyncResult asyncResult)
  {
      HttpWebRequest request = (HttpWebRequest)asyncResult.AsyncState;
      try
      {
          using (HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asyncResult))
          {
              Stream responseStream = response.GetResponseStream();
              using (StreamReader sr = new StreamReader(responseStream))
              {
                  //Need to return this response 
                  string strContent = sr.ReadToEnd();
              }
         }
         manualResetEvent.Set();
      }
      catch (Exception ex)
      {
          throw ex;
     }
  }
  </code></pre>