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.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.xls'. The document may be read-only or encrypted." If you click "OK", it pops up a second error: 'file.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.