title: RangeFileContentResult and Video streaming with Ranged Requests
body: <p>I have an application which intended to stream videos back from our local DB. I spent a lot of time yesterday attempting to return the data a either a <code>RangeFileContentResult</code> or <code>RangeFileStreamResult</code> without success.</p>
  
  <p>In short, when I return the file as either of these two results I cannot seem to get a video to stream correctly (or play at all).</p>
  
  <p>The request from the browser gets sent with the following headers: </p>
  
  <pre><code>Range: bytes=0-
  </code></pre>
  
  <p>And the response comes provided gives these headers as an example:</p>
  
  <pre><code>Accept-Ranges: bytes
  Content-Range: bytes 0-5103295/5103296
  </code></pre>
  
  <p>In terms of network traffic, I get a series of 206's for partial results, then a 200 at the end (according to fiddler) which seems correct. 
  Chrome's network tab disagrees with this and see's an initial request (always 13 bytes which I assume is a handshake) then a couple more requests which have a status of either cancelled or pending. 
  As far as I understand, this is more or less correct, 206 - cancel, 206 - cancel etc. But the video never plays.</p>
  
  <p>If I switch the result from my controller to a FileResult, the video plays and Chrome, IE10 and Firefox and appears to begin playing before the end of the download is completed (which feels a little like it's streaming! although I suspect it's not)</p>
  
  <p>But with the range result I get nothing in chrome or IE and the entire video downloads in one drop in firefox.</p>
  
  <p>As far as I understood, the <code>RangeFileContentResult</code> should handle responding to the client with a range of bytes to download (which mine doesn't seem to do, it just tells it to get the whole file (illustrated by the response above)). And the client should respond to that, which it doesn't seem to do.</p>
  
  <p>Does anyone have any thoughts in this area? Specifically:</p>
  
  <p>a) Should <code>RangeFileContentResult</code> be sending a range of bytes back to the client?
  b) Is there any way I can explicitly control the range of bytes requested from the client side?
  c) Is there any reason or anything I'm doing wrong here which would cause browsers not to load the video at all, when requesting a <code>RangeFileContentResult</code>?</p>
  
  <p>EDIT: Added a diagram to help describe what I'm seeing:</p>
  
  <p><img src="https://i.stack.imgur.com/0kb83.png" alt="RangedRequestImage"></p>
  
  <p>EDIT2: Ok, so the plot thickens. Whilst playing around with the RangedFile gubbins we needed to push another system test version out and I left the 'RangeFileContentResult' on my controller action as below:</p>
  
  <pre><code>private ActionResult RetrieveVideo(MediaItem media)
  {
      return new RangeFileContentResult(
          media.Content, 
          media.MimeType, 
          media.Id.ToString(), 
          DateTime.Now);            
  }
  </code></pre>
  
  <p>Rather oddly, this now seems to work as expected on our Azure system test environment but still not on my local machine. I wonder if there's something IIS based which works happily on Azures IIS8, but not on my local 7.5 instance?</p>