Δ All posts
Fixing File Download Errors in IE with ASP Classic
26 June 2007
Problem 1: "Cannot download" error
"Internet explorer cannot open this internet site"
Likely caused by headers like:
< %Response.Expires = 1 Response.Expiresabsolute = Now() - 1 Response.AddHeader "pragma","no-cache" Response.AddHeader "cache-control","private" Response.cachecontrol = "no-cache" %>
Solution
These must be commented out. Simply callingResponse.Clear() after these doesn't work (for me).
Problem 2: File downloaded ignores content-disposition
This is the case when your script "aspScript.asp" output of file "file.csv" does download, however, instead of saving as "file.csv" it saves as "aspScript" without an extension.Several sources indicated this was caused by an inappropriate Response.ContentType. However, in my case it seems to have been caused by a long filename. I found that the ContentType could be set to "text/plain" or "text/csv" or "text/comma-separated-values" and IE wouldn't care, it seemed only to pay attention to the file extension.Solution
Sacrifice a more meaningful filename in IE for a generic one, sadly, a la:if userAgent.browser = "IE" then Response.AddHeader "Content-Disposition","attachment;filename=export.csv" Response.ContentType = "text/csv" else Response.AddHeader "Content-Disposition","attachment;filename=" & Replace(filename & " - " & NOW()," ","_") &".csv" response.ContentType = "text/csv" end if response.write output.output response.End

Comments
1 carmine says...
I get the following error when I try to open .txt file from my application.
Cannot find the C:Documents and SettingsakhilaLocal SettingsTemporary Internet FilesContent.IE5AVPXGTFXadd[1].txt. Do you want to create a new file??
This error happens when I try to open txt, bmp.
But .doc,.xml works fine with no problem. But If I try to save the files in my local Desktop and open it everything works fine.
Posted at 4:35 p.m. on February 29, 2008
2 pram says...
Hi carmine,
I have the exact same problem you mentioned. I tried lots of things with headers, but didn't work.
Did you find any solution for this issue?
Thanks, Pram
Posted at 11:53 p.m. on March 4, 2008
3 Deanna says...
I tried everything, and found this http://www.gidforums.com/t-12283.html.
I had Response.Clear();
When I added these it worked: Response.ClearHeaders(); Response.ClearContent();
IE apparently will not overwrite the headers. I am using ASP.net, it sees .aspx and puts in a HTML header. That is why the file name and type is incorrect.
Hope this helps, Deanna
Posted at 11:59 a.m. on March 13, 2008