Download like in Microsoft.com

G

Guest

Hi folks,

We want to do downloads as microsoft does in their pages, this is: click on
a button/link, open a new browser where the download is done and the main
browser is redirecting to a "Thanks for download" page. Well, the code we
have is this:

-------------------------------------------------------

- Originalpage.aspx

Response.Write("<script>window.location= 'https://" + serverName + vdirName
+ "thanks.aspx" + "'; window.open('download.aspx','',
'toolbar=no,location=no,directories=no,status=no,menubar=no,
scrollbars=no,resizable=no,copyhistory=no,width=80,height=80,top=0,left=0');</script>");

- Download.aspx (this is the 'popup' window where the download is done)

string PathGUID = "{" + System.Guid.NewGuid().ToString() + "}";
string downloadfile = myFile.CreateFile(a lot of parameters);//creates the
file and returns its name
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" +
downloadfile);
Response.WriteFile(localfile);
Response.Flush();
Response.End();
-------------------------------------------------------

Well, all this code is ok for IE 7, Firefox and so on: it opens a little
window, the other page redirects, the file download dialog box appears,
choose save or open the file, the "popup" window closes in this moment and
the download is done. But this doesn't run ok with IE 5.5. When you choose
save or open file, the popup window doesn't close and also it shows the
typical message "The Web site cannot be found......".

I'd like that this window was closed in any browser and in any case. I've
seen that the microsoft downloads are a little different, because the popup
window is closed just when the file is flushed and you don't have to wait
until the "Save as..." or "Open" buttons are pressed. Maybe this is because
their files are not generated dinamically or do I have something wrong in my
code? You can see an example of the microsoft donloads about I'm talking HERE.

Thanks a lot for any help :)
 
K

Kevin Spencer

Create an HttpHandler that handles the Request.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 

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

Top