title: Empty response HTTPWebRequest: Windows Phone 8
body: <p>I am making a Windows Phone app and I am trying to get JSON data from a URL. The user needs to be logged into the website (which hosts the JSON data) in order to get JSON data and I cannot use the Web Browser control to display the data and then extract the string since the browser doesn't recognize it (for some weird reason) and asks to search for an app on Store which can handle that JSON file type. (If I open the URL in desktop browser on my Windows PC, I can see the raw JSON data). I can't use normal HTTPWebRequest or WebClient as to get JSON data the login cookies needs to be set (the JSON data is user-specific) and I can't extract the cookies from Web browser control and use it with WebClient or HTTPWebRequest. So the best thing I can do is use a special internal instance of IWebRequestCreate that is used internally by the WebBrowser. By opening background HTTP requests with that class, the cookies get automatically set as if they were created/sent by the WebBrowser control. But my code is not returning the JSON data, I get blank response, as in the string <strong>resp</strong> is empty. </p>
  
  <p>Below is the code:</p>
  
  <pre><code>Dim browser = New WebBrowser()
  Dim brwhttp = GetType(WebRequestCreator).GetProperty("BrowserHttp")
  Dim requestFactory = TryCast(brwhttp.GetValue(Browser, Nothing), IWebRequestCreate)
  Dim uri = New Uri("http://api.quora.com/api/logged_in_user?fields=inbox,notifs,following,followers")
  Dim req = requestFactory.Create(uri)
  req.Method = "GET"
  req.BeginGetResponse(New AsyncCallback(AddressOf request_Callback), req)
  
  Private Sub request_Callback(asyncResult As IAsyncResult)
  Dim webRequest As HttpWebRequest = DirectCast(asyncResult.AsyncState, HttpWebRequest)
  Dim webResponse As HttpWebResponse = DirectCast(webRequest.EndGetResponse(asyncResult), HttpWebResponse)
  Dim tempStream As New MemoryStream()
  webResponse.GetResponseStream().CopyTo(tempStream)
  Dim sr As New StreamReader(tempStream)
  Dim resp As String = sr.ReadToEnd
  End Sub
  </code></pre>
  
  <p>What's wrong?</p>