Automatic Download start...

G

Guest

Hi, I am working on a directory type of site and I got stuck in the following
problem:
when the user clicks on the download link I present a page that sais:
"Contacting download site... If the download does not start in 10 sec. please
click the link below". At this point I would like to attempt to download the
file and send it to the client. One think I managed to do is to call a
"DownloadBridge.aspx" page from the Body's onload event and in here I am
overriding the OnLoad and I am trying to put the file into the Request.
Normally, if this file would come from the server itself I would do:

Response.Clear();
Response.AppendHeader("Content-Disposition", "attachment; filename=" +
fileinfo.Name);
Response.AppendHeader("Content-Length", fileinfo.Length.ToString());
Response.ContentType = "application/octet-stream";
s = new System.IO.FileStream(fileinfo.FullName, System.IO.FileMode.Open);
Response.WriteFile(s.Handle, 0, fileinfo.Length);

But the problem is that this time, the source of the file is not a physical
location on the server, instead it is an URL to a different location, let's
say "www.whatever.com/file.zip". How do I take the stream from the source
file and send it with the request to the client? Also, I hope this can be
achieved without the need to actually download the file on the server and
then sending it to the client with the method above... I just want to
transfer the stream...

Any help appreciated,

Thank you,

Iulian
 
G

Guest

Ok, I was able to do it... In the page load event I used:

string scriptString = "<script language=JavaScript> function DoStartup() {";
scriptString += "downloadTimer = setTimeout('startDownloadTimer()', 1000);}";
scriptString += "function startDownloadTimer() {";
scriptString += "clearTimeout(downloadTimer);";
scriptString += "location.href='" + program.Download1 + "';}<";
scriptString += "/";
scriptString += "script>";
if(!this.Page.IsStartupScriptRegistered("Startup"))
this.Page.RegisterStartupScript("Startup", scriptString);

I worked!

Thanks,

Iulian Ionescu
http://www.olvio.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top