Posted by Cynic | Posted in .NET, Internet, Solutions to Problems, Web Sites | Posted on 07-03-2011
Tags: Internet Explorer, MIME Types
Internet Explorer 7/8 throws an error when you pop a download through a meta refresh or iframe. The error message looks like this (I’ve blurred the domain as it’s not public yet):
Searching around didn’t reveal anything of any particular use. Most “solutions” were for clients, which when you’re running a server, doesn’t help much.
Anyways, I decided to go back to basics, and try something really simple… Change the MIME type.
While the MIME type should be “application/octet-stream” for a binary setup file (program installer). However, simply changing it to “application/zip” fixes the problem in Internet Explorer, and popping meta refresh downloads then works.
In code (ASP.NET/C#):
// This does not work: Response.ContentType = "application/octet-stream"; // This works: Response.ContentType = "application/zip";
Now, I’m quite certain you could put in some other MIME type to get a popped download working, but it really doesn’t matter much whether it’s “zip” or “x-gzip” or “x-lick-me-internet-explorer”, just so long as it works.
In any event, the point is that Internet Explorer does not like “octet-stream” MIME types for popping downloads. This makes sense though as you kind of need to know a bit about what you’re doing to mess around with MIME types, and it limits the ability of spammers to distribute malware, or at least the low-level spammers that don’t really understand much more than what they read in spam forums.
I hope that helps someone avoid a bit of pain.