Question : ASP.NET-created Excel files don't work properly in IE 8

Hi,

I have an ASP.NET web application that allows users to download reports and the contents of databases as Excel files, using the following construct:

        Dim context As HttpContext = HttpContext.Current
        context.Response.ClearHeaders()
        context.Response.ClearContent()
        context.Response.Clear()
        context.Response.AppendHeader("Content-Encoding", "text/html")
        context.Response.AppendHeader("Content-Type", "application/vnd.ms-excel")
        context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + name + ".xls")

And then the user is prompted to Open or Save the file.

In IE 5, 6, and 7, Firefox 2 and 3, Opera, and every browser I've used recently, this works flawlessly. If you click "Open", the file opens in Microsoft Excel (provided the user has it).

But it doesn't work in IE 8. Once I click "Open", it starts Microsoft Excel, and then Excel says "Excel cannot access 'file[1].xls'. The document may be read-only or encrypted."  If you click "OK", it pops up a second error: 'file[1].xls' cannot be accessed. The file may be corrupted, located on a server that is not responding, or read-only".

If I choose "Save" instead of "Open", the file saves just fine.

If I set IE 8 to "Compatibility Mode" for my page, "Open" works just fine.

Adding the site to the "Trusted Sites" list made no difference.

So, I know this is an IE 8 issue, I just don't know how to solve it. I think it has something to do with how IE 8 saves the temporary files. Not sure.

Any suggestions?

Answer : ASP.NET-created Excel files don't work properly in IE 8

You does not seem to be alone with this problem
http://www.winvistatips.com/pdf-attachments-not-open-after-ie8-t175086.html

There is no fix or workaround yet.

>context.Response.AppendHeader("Content-Encoding", "text/html")
BTW, xls files are not html!
Random Solutions  
 
programming4us programming4us