<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d8211560\x26blogName\x3dTech+Tips,+Tricks+%26+Trivia\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttp://mvark.blogspot.com/search\x26blogLocale\x3den\x26v\x3d2\x26homepageUrl\x3dhttp://mvark.blogspot.com/\x26vt\x3d-5147029996388199615', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

Tech Tips, Tricks & Trivia

by 'Anil' Radhakrishna
An architect's notes, experiments, discoveries and annotated bookmarks.

Search from over a hundred HOW TO articles, Tips and Tricks


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.

Labels: ,

Tweet this | Google+ it | Share on FB

« Home | Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »

»

Post a Comment