I have an issue with my website and IE. I have a file Document.ashx that becomes a document from my database depending on the parameter passed in the query
dynamic create Iframe ,set the src to the download page loaction , append to the body.
function downloadInIFrame(fileId) {
var url = "download.aspx?fileId=" + fileId;
var iframe = document.createElement("iframe");
iframe.src = url;
iframe.style.display = "none";
document.body.appendChild(iframe);
}
those code works well for me.
It sounds like I problem I came accross with IE 8 only. When I was tracking down a solution I came across 2 solutions. One of them should correct this issue.
Just to let you know it is a fix on the client machine as it is how IE coded that causes the issue.
Fixes: http://support.microsoft.com/kb/815313 http://support.microsoft.com/kb/323308
This issue is caused by a browser setting in Internet Explorer. In Internet Explorer go to Tools
> options
> Advanced options
. In the section marked Security, locate and clear the Do not save encrypted pages to disk.
Just like rymo said set Cache-Control: private
, If your response header happen to have the Pragma :no-cache
, you also have to change it to Pragma: token
.
if you using asp.net. remove the code with sets cache
Comment the following
Response.Clear();
Response.Buffer = true;
Response.Charset = "";
**//Response.Cache.SetCacheability(HttpCacheability.NoCache);**
Response.ContentType = contentType;
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
We had this same issue with IE8 using an MVC controller tagged with NoCache. This sets Response.Cache.SetNoStore
which breaks file downloads in IE.
To resolve - you can reset the Http Cache Policy via reflection.