Note that there are some explanatory texts on larger screens.

plurals
  1. POHttpWebRequest BeginGetResponse callback not firing on WP8 (working on WP7)
    text
    copied!<p>I'm having a problem with a previous app not working on WP8, which works perfectly on WP7.</p> <p>This is the code I'm using for the http request:</p> <pre><code>public void SendMessage() { request = WebRequest.Create(uri) as HttpWebRequest; request.Method = "POST"; request.AllowReadStreamBuffering = true; request.ContentType = "application/octet-stream"; try { // get device info String deviceInfo = String.Format("platform,{0};os,{1};width,{2};height,{3};dpi,{4};", Config.PLATFORM_NAME, Environment.OSVersion.Version.ToString(), System.Windows.Application.Current.Host.Content.ActualWidth.ToString(), System.Windows.Application.Current.Host.Content.ActualHeight.ToString(), 96); request.Headers["X_MX_DEVICE_INFO"] = deviceInfo; } catch (Exception) {} request.BeginGetRequestStream(new AsyncCallback(ProcessRequestStream), null); } private void ProcessRequestStream(IAsyncResult asyncResult) { if (!message.IsCancelled()) { try { using (Stream stream = request.EndGetRequestStream(asyncResult)) { message.GetRequest(stream); } request.BeginGetResponse(new AsyncCallback(ProcessResponseStream), null); } catch (Exception e) { syncContext.Post(OnEnd, e); } } else { syncContext.Post(OnEnd, null); } } private void ProcessResponseStream(IAsyncResult asyncResult) { if (!message.IsCancelled()) { try { response = (HttpWebResponse)request.EndGetResponse(asyncResult); if (HttpStatusCode.OK != response.StatusCode) { throw new Exception("http status error: " + response.ToString()); } syncContext.Post(SetResponse, response); } catch (Exception e) { syncContext.Post(OnEnd, e); } } else { syncContext.Post(OnEnd, null); } } private void SetResponse(object state) { Exception ex = null; try { using (Stream stream = ((HttpWebResponse)state).GetResponseStream()) { message.SetRespone(stream); } } catch (Exception e) { ex = e; } syncContext.Post(OnEnd, ex); } private void OnEnd(object state) { message.OnEnd((Exception)state); } } </code></pre> <p>It looks as though BeginGetResponse's callback isn't being fired. I've tried Fiddler to see what response is coming back, and looks as though nothing is even coming back, but just for WP8.</p> <p>Any possible reasons for this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload