title: Stream returned by Http response is not seekable as response.Length throws "unsupported"
body: <p>I'm trying to read the bytes from a file that I've retrieved from an external source, however when running the code I get the following error: </p>
  
  <pre><code>System.NotSupportedException: Specified method is not supported.\r\n   at System.Net.Http.HttpBaseStream.get_Length()
  </code></pre>
  
  <p>My code in question is as follows: </p>
  
  <pre><code>var responseBody = (request.GetResponseAsync().Result).GetResponseStream();
  
          byte[] file;
          var br = new BinaryReader(responseBody);
          file = br.ReadBytes((int)br.BaseStream.Length);
          using (MemoryStream ms = new MemoryStream())
          {
              int read;
              while ((read = responseBody.Read(file, 0, file.Length)) &gt; 0)
              {
                  ms.Write(file, 0, read);
              }
          }
  
          var result = new MemoryStream(file);
  </code></pre>
  
  <p>It fails on the following line: </p>
  
  <pre><code>  file = br.ReadBytes((int)br.BaseStream.Length);
  </code></pre>
  
  <p>I can't seem to find a solution to the issue, can anyone suggest a fix? </p>