IE Information Bar, download file...how do I code for this?

Posted by flatline on Stack Overflow See other posts from Stack Overflow or by flatline
Published on 2009-05-27T13:40:29Z Indexed on 2010/04/13 16:03 UTC
Read the original article Hit count: 216

Filed under:
|
|

I have a web page (asp.net) that compiles a package then redirects the user to the download file via javascript (window.location = ....). This is accompanied by a hard link on the page in case the redirect doesn't work - emulating the download process on many popular sites. When the IE information bar appears at the top due to restricted security settings, and a user clicks on it to download the file, it redirects the user to the page, not the download file, which refreshes the page and removes the hard link.

What is the information bar doing here? Shouldn't it send the user to the location of the redirect? Am I setting something wrong in the headers of the download response, or doing something else wrong to send the file in the first place?

C# Code:

m_context.Response.Buffer = false;
m_context.Response.ContentType = "application/zip";
m_context.Response.AddHeader("Content-Length", fs.Length.ToString());
m_context.Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}_{1}.zip", downloadPrefix, DateTime.Now.ToString("yyyy-MM-dd_HH-mm")));
//send the file

© Stack Overflow or respective owner

Related posts about internet-explorer

Related posts about ASP.NET