HOW TO programmatically implement resumable downloads

The resumable download solution comes via some little-known features in the HTTP 1.1 protocol - Accept-Ranges and Etag.

The Accept-Ranges header element quite simply tells the client/Web browser, that this process supports resumable downloads. The Entity Tag, or Etag, element specifies a unique identifier for the session.

Because of ETag and Accept-Headers, the browser knows that the Web server will support resumable downloads.

The downloadable code and detailed explanation are well presented in the MSDN Mag article "Build Smarter ASP.NET File Downloading Into Your Web Applications"

The article also discusses various ways to implement File Downloading functionality in Web Apps using ASP.NET, like:
* Response.WriteFile method
* Streaming the file using the Response.BinaryWrite method
* Using the Response.TransferFile method in ASP.NET 2.0
* Using an ISAPI filter
* Writing to a custom browser control

By manipulating the Content-Disposition HTTP header, a file can be forced to be downloaded with a pre-set file name which may not be the actual file name -
Response.AppendHeader("Content-Disposition", "attachment;Filename=UML.pdf");

It is possible to avoid memory usage problems while downloading huge files by using Response.TransmitFile (available in ASP.NET 2.0) or writing File Chunks to the Client

IIS itself does not support file downloads greater than 2GB in size. If you require larger downloads, you will need to use FTP, a third-party control, the Microsoft Background Intelligent Transfer Service (BITS), or a custom solution like streaming the data through sockets to a browser-hosted custom control.

To maintain MS Office formatting features in download-able Word & Excel files that are dynamically generated, Office XML can be used.

Comments