3 Answers
3

Don't use Response.Write or Response.WriteFile to force file-download because that will simply not help in this context.

In order to do what you want, save the zipped file on disk and redirect the user to download-file. You can create a temp folder to hold the zipped files which you create on the fly and flush them every one hour or any such predefined time-interval. You need to call this from standard post-back driven non-ajaxed call. This will preserve the state.

There is no reason to request the file with an AJAX callback, as downloading the file doesn't refresh the page and therefore the user doesn't lose the context, which is usually the reason why you would prefer AJAX callback.

According to your comments, there are 2 ways to overcome the problem :

You can write into the response stream at the same time that you are downloading the file from the second server and therefore making the progress visible in the open/save dialog of the browser.

You can temporarily store the file somewhere in the database / file system and send it with a second request made directly by the user.

The first one seems more reasonable to me as you don't have to deal with the intermediate storage.

I have a rad grid on my page which have link buttons. On click of any link button, i need to get the file from another server to the application server and then download the file to client. Since there might be delays in downloading file, i need to notify the user that file is getting downloaded. Thus i am using rad ajax manager to show a downloading panel till the file is downloaded.
–
AnkitJan 18 '10 at 9:59

There is always a delay when downloading file, but each browser has a dialog for that which works in a standard and by the users expected way (e.g. all the downloads at one tab in Chrome or single popup with downloads in Safari/Firefox etc.). Why would you want to reimplement such a behavior in a different way ?
–
Tomas VanaJan 18 '10 at 10:04

The open/save file dialog box shows the download progress from app server to client machine. The time consuming task in my application is retreiving file from an external server to the application server and then sending it to client
–
AnkitJan 18 '10 at 10:08

I see, then I would probably divide this functionality, make a request just to retrieve the file from the external server which shows the progress and notifies about success when it's done and then let the user simply click on the link when it's done and download the file using the standard mechanism.
–
Tomas VanaJan 18 '10 at 10:13

The third server is not visible to the end users. So i need to download the file on one go.
–
AnkitJan 18 '10 at 10:17

I am not zipping the file on JS. M using another tool for doing it.
–
AnkitJan 18 '10 at 10:02

I never said you were. You are sending a zipped file as the response. If you want JS to do anything useful with it you will have to unzip it in JS.
–
QuentinJan 18 '10 at 10:06

For that i need to download the file to client machine which is very large. So i want to compress it and then send it to client. Further, the problem is not with zipping, it is while sending the file using response.write method on ajaxified page.
–
AnkitJan 18 '10 at 10:10

As mentioned. You can send the file to the client. The question is — what do you want the client to do with it? If you send it using Ajax, then the file can only be processed with JavaScript, and I can't think of anything that can usefully be done there without unzipping it.
–
QuentinJan 18 '10 at 10:28

David, the problem is not zipping / unzipping the file
–
AnkitJan 18 '10 at 10:36