auto download with page redirection

C

Carlo

I am trying to seek the following functionality:

A user clicks on a download buton
he is redirected to another page
download automatically begins while in page.

I can automatically download a file, but since in the end i must end the
response, its either the download or the page display.

To dowload the file i am using the following code:

Response.ContentType = "application\\octet-stream";

string filename = BaseComponents.GetDownloadLink(productRef);

System.IO.FileStream downloadFile = new System.IO.FileStream(filename,
System.IO.FileMode.Open);

Response.AddHeader("Content-Disposition", "attachment; filename=" +
downloadFile.Name);

Response.AddHeader("Content-Length", downloadFile.Length.ToString());

Response.Write(downloadFile.Length + "#");

downloadFile.Close();

Response.WriteFile(filename);

Response.Flush();

Response.End();
 
B

bruce barker

you can not send both a file and a redirect. the usual solution to this
is to have the download load into a new window, then the current page is
free to redirect whenever it wants. the hickup is that the original page
can not tell when the download is done. it can poll the server to see if
the server send is complete, but can not tell if the last block was
received.

-- bruce (sqlwork.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,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top