title: Efficiently sending files from asp.net core
body: <p>I am interested in porting some code to ASP.NET Core and wanted to know the most efficient way to send files, aka "download" files, from an ASP.NET Core web service.</p>
  
  <p>With my old ASP.NET code, I was using a FileStream:</p>
  
  <pre><code>var content = new FileStream(
      myLocation,
      FileMode.Open, FileAccess.Read, FileShare.Read);
  
  var result = new HttpResponseMessage(HttpStatusCode.OK)
  {
      Content = new StreamContent(content)
  };
  </code></pre>
  
  <p>However, I was trying to find the .NET equivalent of FreeBSD's sendfile() and found <strong>HttpResponse.TransmitFile</strong> .  I assume this would be faster?</p>
  
  <p>I am also concerned that the file will have to make an extra hop out of Kestrel, to IIS, before hitting the user.  Any advice?</p>