|"Snippets" are mini-articles - they allow me to very quickly add answers to your frequently asked questions, and add brief explanations for topics that you've searched for without success. So, everytime you send an email or perform a search, chances are a new snippet will be the result!|
10 Oct: Auto-downloads using Response.AddHeaderRecently I was writing a page for a customer that has a lot of programs that you can download demonstration versions of. The plan was to show some instructions about how to install the demo and have the download start automatically after a few seconds.
To do this I called Response.AddHeader to tell the browser to reload the zip file after 3 seconds. zip files are usually handled by the browser displaying a File Download dialog box allowing you to run or save the file to disk.
Here's how it works:
Response.AddHeader ( 'Refresh', '3; URL=http://www.yourdomain.com/downloads/' + sName + '.zip' );
I had retrieved the name of the download from the database and placed it in the sName variable before the call.
You must specify an absolute URL - not a relative path to the file on the server. Remember, this will be acted upon by the browser on the client-side, not by the server.
Headers can only be added in this way if Response buffering is enabled. This is the default in IIS 5.0, but it's safer to add the following line to the top of your page to be sure. (In the CYA code this line is part of the include/startup.asp file that is included in every page):