473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

auto download with page redirection

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();

Dec 14 '06 #1
1 1408
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)

Carlo wrote:
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();
Dec 14 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: James T Kirk | last post by:
How can I create a link to a zip/exe file, that will start a download and then redirect to another page. The files being downloaded will be different, but the page to be directed to will stay...
2
by: Dave | last post by:
Hi, can someone tell me if it's possible and if yes what the script is and where to put it in order to: have the browser check upon loading page X to see if the user's computer has Flash player...
5
by: Josselin | last post by:
I have a page 'pni.php' to which paypal is redirecting after payment thsi page contains a db update script, no problem it's running well but once this script is executed (transparently for the...
0
by: comp.lang.php | last post by:
I have a form that when you click the "Generate Report" submit button, it will force download a CSV file, required for this project. On the very same page you also have a "Search" submit button,...
1
by: walkerhunter | last post by:
Hi all, I am trying to implement something called lightbox for creating modal forms on a webpage. Any way, I want to an auto redirect to occur, but I need the redirect to add in a parameter in...
2
by: PSiegmann | last post by:
Hi newsgroup. Sites which host a large download archive (think download.com) often times don't give you a desired file directly, but redirect you to a page, where you wait usualy 5 secs, and...
2
by: =?Utf-8?B?SHVzYW0=?= | last post by:
Hi EveryBody: I'm working with project in my company by using ASP.Net 2.0 that allow the users to upload and download files to web site in the internet as backup. The user will first upload his...
1
by: =?Utf-8?B?SHVzYW0=?= | last post by:
Hi EveryBody: I have the following code to download the data from my web application: the code is: Dim rawan As New List(Of String) ' for File Name Dim rawan1 As New List(Of Byte()) ' for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.