title: Getting data back from an HttpWebRequest.BeginGetResponse callback
body: <p>I am writing a Windows Phone 8 app that is supposed to send an GET+POST request to a server and parse the answer.</p>
  
  <p>The code I am using to send the request and to get a response back is the following (it is written in a separate static class):</p>
  
  <pre><code>                // server to POST to
          string url = "http://myserver.com/?page=hello&amp;param2=val2";
  
          // HTTP web request
          var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
          httpWebRequest.ContentType = "application/x-www-form-urlencoded";
          httpWebRequest.Method = "POST";
  
          // Write the request Asynchronously 
          using (var stream = await Task.Factory.FromAsync&lt;Stream&gt;(httpWebRequest.BeginGetRequestStream,
                                                                   httpWebRequest.EndGetRequestStream, null))
          {
              // Create the post data
              string postData = "pseudo=pseudo&amp;titre=test&amp;texte=\"Contenu du message\"";
              byte[] byteArray = Encoding.UTF8.GetBytes(postData);
  
              // Write the bytes to the stream
              await stream.WriteAsync(byteArray, 0, byteArray.Length);
              stream.Close();
              IAsyncResult ar = httpWebRequest.BeginGetResponse(new AsyncCallback(GetResponsetStreamCallback), httpWebRequest);
  
          }
  
  
  
      }
  
      private static void GetResponsetStreamCallback(IAsyncResult callbackResult)
      {
          HttpWebRequest request = (HttpWebRequest)callbackResult.AsyncState;
          HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(callbackResult);
          using (StreamReader httpWebStreamReader = new StreamReader(response.GetResponseStream()))
          {
              string result = httpWebStreamReader.ReadToEnd();
              //For debug: show results
              System.Diagnostics.Debug.WriteLine(result);
  
  
  
          }
  </code></pre>
  
  <p>My problem is : I have no idea how to get this answer (the string result) back in my behind-code in my app (or any other method in my app to be honest).</p>
  
  <p>How could I do that?</p>