title: Handling HTTP 302 with HttpClient on WP8
body: <p>I am facing a really complicated problem with the app I am developing for Windows Phone 8. The following endpoint - <a href="http://speedmeter3.internetprovsechny.cz:81/ping/" rel="nofollow">http://speedmeter3.internetprovsechny.cz:81/ping/</a> - can be used to measure the latency of connected client. The result is stored as JSON string and is returned. However, to perform the measurement, there are several HTTP 302 (Found) redirects used (always returning to the same URL). The result is correctly returned in browsers and I have seen numerous ways to solve similar problem on Android, but have found none that works on Windows Phone.
  Here is my simple code snippet that should return the string:</p>
  
  <pre><code>HttpClientHandler handler = new HttpClientHandler();
  handler.AllowAutoRedirect = true;     
  HttpClient client = new HttpClient( handler );
  string url = "http://speedmeter3.internetprovsechny.cz:81/ping/";
  return await client.GetStringAsync( new Uri( url, UriKind.Absolute ) );
  </code></pre>
  
  <p>This code hangs for a while on the GetStringAsync method and eventually terminates with exception: </p>
  
  <pre><code>System.Net.Http.HttpRequestException: Response status code does not indicate success: 302 (Found).
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
     at IPVSpeedmeter.Helpers.RestClient.&lt;SendGetSafe&gt;d__8.MoveNext()}    System.Exception {System.Net.Http.HttpRequestException}
  </code></pre>
  
  <p>Anyone who is able to provide a solution for this will be awarded a bounty when it will be possible (after three days ;-) ).</p>
  
  <p>Thank you all</p>