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.
With my old ASP.NET code, I was using a FileStream:
var content = new FileStream(
myLocation,
FileMode.Open, FileAccess.Read, FileShare.Read);
var result = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StreamContent(content)
};
However, I was trying to find the .NET equivalent of FreeBSD's sendfile() and found HttpResponse.TransmitFile . I assume this would be faster?
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?