title: Partial content in .NET Core MVC (for video/audio streaming)
body: <p>I am trying to implement video and audio streaming on my website (to enable seeking in Chrome) and I recently found out that .NET Core 2.0 apparently provides a relatively simple and recommended way of implementing this using <code>FileStreamResult</code>.</p>
  
  <p>This is my simplified implementation of the Action that returns the FileStreamResult:</p>
  
  <pre><code>    public IActionResult GetFileDirect(string f)
      {
          var path = Path.Combine(Defaults.StorageLocation, f);
          return File(System.IO.File.OpenRead(path), "video/mp4");
      } 
  </code></pre>
  
  <p>The <code>File</code> method has the following (shortened) description: </p>
  
  <blockquote>
    <p>Returns a file in the specified fileStream (Status200OK), with the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable)</p>
  </blockquote>
  
  <p>But for some reason, the server still does not respond correctly to range requests.</p>
  
  <p>Am I missing something?</p>
  
  <hr>
  
  <h2>Update</h2>
  
  <p>Request sent from Chrome looks like this</p>
  
  <pre><code>GET https://myserver.com/viewer/GetFileDirect?f=myvideo.mp4 HTTP/1.1
  Host: myserver.com
  Connection: keep-alive
  Accept-Encoding: identity;q=1, *;q=0
  User-Agent: ...
  Accept: */*
  Accept-Language: ...
  Cookie: ...
  Range: bytes=0-
  </code></pre>
  
  <p>Response looks like:</p>
  
  <pre><code>HTTP/1.1 200 OK
  Server: nginx/1.10.3 (Ubuntu)
  Date: Fri, 09 Feb 2018 17:57:45 GMT
  Content-Type: video/mp4
  Content-Length: 5418689
  Connection: keep-alive
  
  [... content ... ]
  </code></pre>
  
  <p>Also tried using the following command:
  <code>curl -H Range:bytes=16- -I https://myserver.com/viewer/GetFileDirect?f=myvideo.mp4</code> and it returns the same response.</p>
  
  <p>The HTML is pretty straightforward too.</p>
  
  <pre><code>&lt;video controls autoplay&gt;
      &lt;source src="https://myserver.com/viewer/GetFileDirect?f=myvideo.mp4" type="video/mp4"&gt;
      Your browser does not support the video tag.
  &lt;/video&gt;
  </code></pre>
  
  <p>The video DOES start playing - the user is only unable to seek the video.</p>