简体   繁体   中英

What's the best practice for transferring huge binary files with ASP.NET?

Consider an ASP.NET page with this code:

while (read)
{
   Response.OutputStream.Write(buffer, 0, buffer.Length);
   Response.Flush();
}

The application should be highly performance-tuned and handle thousands on concurrent requests and the main purpose is transferring huge binary file to clients over high speed connections. I can do the job with an ASP.NET page , with HTTP Handler , IHttpAsyncHandler , ISAPI filter and ...

The question is what is the best choice for this purpose ?

If the page is liable to be I/O bound then I'd go the Async road. But you should use the asynchronous read methods (if available) on your Stream object as well.

For more information see:

FileStream Constructor - with async example

To address your comment that you receive this data via a socket, you'll also find that most of the System.Net.Sockets namespace classes support asynchronous behaviour.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM