title: HttpClient GetAsync hanging
body: <p>I have an identical method in two of my WP8 apps. Given the same url and same device, the method works on one app, but not the other. In the failing app, GetAsync is hanging after it is called. No time out, no exception.</p>
  
  <p>Here is the method in question.</p>
  
  <pre><code>    private async Task&lt;Byte[]&gt; DownloadData(string uri)
      {
          byte[] myDataBuffer = null;
          var newUri = new Uri(uri, UriKind.Absolute);
          var myWebClient = new HttpClient();
  
          var response = await myWebClient.GetAsync(newUri);
          if (response.Content.Headers.ContentType.MediaType == "text/plain"
              || response.Content.Headers.ContentLength &lt; 200)
          {
              throw new Exception(await response.Content.ReadAsStringAsync());
          }
          myDataBuffer = await response.Content.ReadAsByteArrayAsync();
          return myDataBuffer;
      }
  </code></pre>
  
  <p>This happens every time on one particular app, but not the other. Same device. Has anybody ever experienced this behavior? The url is valid, the code is identical. Is there a project setting somewhere that might affect this? I'm using the HttpClient in another portion of the failing app and it works there.</p>
  
  <p>I can change the code to use a HttpWebRequest and that works fine. Just not the HttpClient.</p>
  
  <p>I just now discovered that if I copy the method into my button_click handler, it works there too. Is there a problem having this method inside a separate class? That seems odd to me.</p>
  
  <p><em>update</em></p>
  
  <p>What seems to be breaking it is multiple layers of async methods calling it. Within the class I have</p>
  
  <pre><code>    public override byte[] GetImageData(string imageUri)
      {
          return GetImageDataAsync(imageUri).Result;
      }
  
      public async Task&lt;byte[]&gt; GetImageDataAsync(string imageUri)
      {
          return await DownloadData(imageUri);
      }
  </code></pre>
  
  <p>from my button_click handler, I'm calling <code>GetImageData(uri)</code>. If I change that to <code>await GetImageDataAsync(uri)</code> it works.</p>
  
  <p>Is <code>Result</code> not the correct property to reference in <code>GetImageData</code>?</p>
  
  <p>Here's a test url "<a href="http://www.rei.com/pix/common/REI_logo.gif" rel="noreferrer">http://www.rei.com/pix/common/REI_logo.gif</a>"</p>