title: HttpWebRequest.BeginGetResponse on WP8
body: <p>I have a problem with WebRequest in a PCL (Portable Class Library) again.</p>
  
  <p>I have this piece of code:</p>
  
  <pre><code>    static ManualResetEvent allDone = new ManualResetEvent(false);
      static string doc;
  
      static public void AddAnime(string encodedLogin, string id, int episodes, int status, int score)
      {
          if (string.IsNullOrEmpty(encodedLogin))
          {
              throw new ArgumentException();
          }
          else
          {   
              doc = String.Format("anime_id={0}&amp;status={1}&amp;episodes={2}&amp;score={3}", id, "watching", episodes, score);
  
              HttpWebRequest request = HttpWebRequest.CreateHttp("http://mal-api.com/animelist/anime");
  
              request.Method = "POST";
              request.Headers["Authorization"] = encodedLogin;
  
              request.BeginGetRequestStream(new AsyncCallback(GetRequestCallBack), request);
  
              allDone.WaitOne();
  
              s.ToString();
          }
      }
  
      static private void GetRequestCallBack(IAsyncResult aResult)
      {
          HttpWebRequest request = (HttpWebRequest)aResult.AsyncState;
  
          Stream postStream = request.EndGetRequestStream(aResult);
  
          byte[] byteArray = Encoding.UTF8.GetBytes(doc);
  
          postStream.Write(byteArray, 0, doc.Length);
          postStream.Flush();
  
          request.BeginGetResponse(new AsyncCallback(GetResponseCallback), request);
      }
  
      static private void GetResponseCallback(IAsyncResult asyncResult)
      {
          HttpWebRequest request = (HttpWebRequest)asyncResult.AsyncState;
  
          HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asyncResult);
  
          Stream dataStream = response.GetResponseStream();
          StreamReader streamReader = new StreamReader(dataStream);
  
          string responseString = streamReader.ReadToEnd();
  
          //Do something with string here
  
          allDone.Set();
      }
  </code></pre>
  
  <p>Now, the problem is, when I call <code>AddAnime</code> in a sample Console app, this runs perfectly fine, but when I call it from my WP8 device or emulator (WXGA), it gets stuck on <code>BeginGetResponse</code>. It doesn't enter <code>GetResponseCallback</code> at all (tested with breakpoints), and doesn't continue with any code directly after <code>BeginGetResponse</code> either. I've waited for more than two minutes, which should throw a <code>TimeOutException</code> (I think), but even then nothing at all happened.</p>
  
  <p>I tested with:</p>
  
  <ul>
  <li>Console app (works)   </li>
  <li>WP8 WXGA emulator (doesn't work)   </li>
  <li>WP8 Device connected (doesn't work)  </li>
  <li>WP8 Device disconnected (doesn't
  work)</li>
  </ul>
  
  <p>For my PCL I target:</p>
  
  <ul>
  <li>SL4 and higher</li>
  <li>WP7 and higher</li>
  <li>Windows Store</li>
  <li>.NET 4.5</li>
  </ul>
  
  <p>How could I solve this? Isn't a PCL used to guarantee cross-compatibility?</p>