473,769 Members | 2,103 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Conten tType = "application\\o ctet-stream";

string filename = BaseComponents. GetDownloadLink (productRef);

System.IO.FileS tream downloadFile = new System.IO.FileS tream(filename,
System.IO.FileM ode.Open);

Response.AddHea der("Content-Disposition", "attachment ; filename=" +
downloadFile.Na me);

Response.AddHea der("Content-Length", downloadFile.Le ngth.ToString() );

Response.Write( downloadFile.Le ngth + "#");

downloadFile.Cl ose();

Response.WriteF ile(filename);

Response.Flush( );

Response.End();

Dec 14 '06 #1
1 1432
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.Conten tType = "application\\o ctet-stream";

string filename = BaseComponents. GetDownloadLink (productRef);

System.IO.FileS tream downloadFile = new System.IO.FileS tream(filename,
System.IO.FileM ode.Open);

Response.AddHea der("Content-Disposition", "attachment ; filename=" +
downloadFile.Na me);

Response.AddHea der("Content-Length", downloadFile.Le ngth.ToString() );

Response.Write( downloadFile.Le ngth + "#");

downloadFile.Cl ose();

Response.WriteF ile(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
21819
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 the same. I want the redirect to happen as soon as the download begins... How can I do this ?
2
6709
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 installed. If answer is "no", then browser loads page Y instead of page X. Would such a check, if possible, be likely to be cross-browser/platform understood?
5
7587
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 use, as there is nothing to display) how can I redirect to another page ? header redirect can only be placed at the beginning of the page... not at the end I've already writen redirection but only when there was a form inside
0
2662
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, when you press it it should generate search results in a new page. However, when you click the "Generate Report" submit button, the moment you try to THEN click the "Search" submit button, the "Search" submit button NEVER goes to a new page but...
1
1502
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 addition to the URL. The way I have seen this parameter passed in is via a link like so: <a href="form.html" class="lbOn">Click here</a>
2
1085
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 then the download appears.. What is the benefit of that? Why not offer the file immediately.. is it for performance? I ask, because I am currently working on a site, which will host too some sort of download-archive. My current design is to give...
2
1687
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 or her own files in the website that will save the data immediatlly into database. and when the user sign in into his or her account he can download his own files.
1
1696
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 the data for each file Dim objconn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("Husam").ConnectionString)
0
10199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9981
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9850
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8862
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7396
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3948
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3551
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.