I am developing an application that allows the user to download an excel file with regular content(not bigger then a few Mb).
On IE9 the file gets downloaded perfectly, but on IE8 some of the pages that allow the download does not work.
A new page is opens and closed right away without showing the download bar.
The cache control header is set to private.
I have disabled all of my IE8 add ones.
I have matched the response from the server for both the page that does allow the file saving and the one that does not work and they match exactly ( apart from the path )
I dont know why on some cases the file gets download perfectly and on others it dont.
Here is the server side code that I use to download the file:
protected void GetExportedFile()
{
string filename = Form("filename");
if (string.IsNullOrEmpty(filename))
{
Logger.Instance.Write("GetExportedFile is missing the parameter filename");
Response.Redirect("ErrorPage.aspx");
}
string filePath = Context.Server.MapPath("****/****/" + filename);
Response.ClearHeaders();
Response.ClearContent();
SetContentType(ContentType.Excel);
Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", filename));
Response.WriteFile(filePath);
Response.Flush();
try
{
File.Delete(filePath);
}
catch (Exception ex)
{
Logger.Instance.Write(
"GetExportedFile failed to delete the file '" + filePath +
"', Error: " + ex.ToString(), "Error");
}
try
{
Response.End();
}
catch (ThreadAbortException ex)
{
//Don't add anything here.
//because if you write here in Response.Write,
//that text also will be added to your text file.
}
}
I have to mention although I dont think it is relevant that prior to the downloads that don't work on IE8 I am making some ajax calls to get notify if the excel generation has finished, while on the page that does work I dont do this procedure.
I will also like to add that my application resides behind an application firewall (F5) and when deactivated makes all of the downloads work on IE8, the issue is I am not not seeing any changes in the response.
thanks