Solved

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

Posted on 2009-05-18
7
1,908 Views
Last Modified: 2013-12-08
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?
0
Comment
Question by:CMES-IT
  • 3
  • 2
7 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 24419394
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!
0
 

Author Comment

by:CMES-IT
ID: 25150837
I'm not sure that it's fair to accept a solution that there is no solution.

I don't care if you give him the points and close the question,  but if someone is looking for a solution to this problem, this is not a good answer.

Someone out there has figured out how to do Excel downloads in IE8. I am sure of it.
0
 
LVL 29

Expert Comment

by:Badotz
ID: 25151216
>>I'm not sure that it's fair to accept a solution that there is no solution.

If that is the only answer, then why is it not acceptable?


You said:

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

Isn't that the solution?
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:CMES-IT
ID: 25152468
No, that's not the solution. I'm not the only one using my page, so my browser settings don't matter.

Now, there is a function for IE 8 where you add a line of code to the page header, and IE 8 forcefully renders the page in IE 7.

But, that still is not a solution. That's a hack.

To admit that there is no solution, or use the hack, is to admit that Microsoft purposefully broke Internet Explorer 8's ability to handle Excel files, and I find that highly unlikely, don't you?

The point of this being - perhaps EE doesn't have the answer. And that's disappointing, but acceptable. However, just because no one here reading this thread has the answer, doesn't mean there is one, and I don't think something should be marked as a solution when it isn't.
0
 
LVL 29

Expert Comment

by:Badotz
ID: 25152610
Highly unlikely that they broke it on purpose? Yes.

Highly unlikely that they broke it? Nope. I've written enough software to understand how that could happen.

If you can determine that there *is* a solution, then post it here. We have access to the same tools as you, but our need for a fix may be not be as great as yours.
0
 
LVL 29

Expert Comment

by:Badotz
ID: 25152619
"may be not be as great as yours"

Sheesh, even Yoda wouldn't say that ;-)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Several part series to implement Internet Explorer 11 Enterprise Mode
SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now