468,780 Members | 2,296 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,780 developers. It's quick & easy.

Automatic Download start...

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

Nov 19 '05 #1
1 1643
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/
--
Regards,

Iulian
"Iulian" wrote:
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

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by William Ryan | last post: by
2 posts views Thread by Trygve Lorentzen | last post: by
1 post views Thread by rdemyan via AccessMonster.com | last post: by
2 posts views Thread by Jan Paul van de Berg | last post: by
6 posts views Thread by Mike Saunders | last post: by
25 posts views Thread by sidd | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.