Office documents will be recognized as .zip file when downloading from IE
Symptom
When we try to download some Office documents with OpenXML format(Office 2007 or later), the document will be probably identified as an zip file as below.
If you try to save the file, the file extension could also be .zip instead of .docx.
This problem only happens on IE6,7,8. It’s fine with IE9 or other web browsers.
Root Cause
This problem is caused by the MIME Sniffing feature of IE. For more information about how IE sniffs MIME type, please refer to https://msdn.microsoft.com/en-us/library/ms775148(VS.85).aspx
If Internet Explorer knows the Content-Type specified and there is no Content-Disposition data, Internet Explorer performs a "MIME sniff," scanning the first 200 bytes of the file to determine if the file structure matches any known MIME types. For more information on MIME sniffing, see MIME Type Detection in Internet Explorer. If the MIME sniff detects a MIME type known to Internet Explorer, and the file has not been loaded by a mimefilter already, Internet Explorer sets that file name extension before placing the file in the local browser cache.
Actually, OpenXML is a zipped, XML-based file format developed by Microsoft.
This is why the .docx file is recognized as a .zip file.
If you capture a HTTP trace of this request, you will always get the below Content-Type
(Status-Line) HTTP/1.1 200 OK
Cache-Control public
Content-Length 61568
Content-Type application/octet-stream
Date Tue, 27 Mar 2012 05:10:22 GMT
……
Solution
There are two options to resolve the issue.
l Disable MIME Sniffing from server side
We only need to add the below custom HTTP header from web server
X-Content-Type-Options: nosniff
You can refer to https://technet.microsoft.com/en-us/library/cc753133(v=WS.10).aspx to learn how to add header on IIS7.
l Set the proper Content-Type for OpenXML documents
To do so, we need to add the correct MIME type on the web server side.
Please refer to https://technet.microsoft.com/en-us/library/cc725608(v=WS.10).aspx to learn how to add MIME type on IIS7. Here’s the list of the MIME types for Office documents.
docm |
application/vnd.ms-word.document.macroEnabled.12 |
docx |
application/vnd.openxmlformats-officedocument.wordprocessingml.document |
dotm |
application/vnd.ms-word.template.macroEnabled.12 |
dotx |
application/vnd.openxmlformats-officedocument.wordprocessingml.template |
ppsm |
application/vnd.ms-powerpoint.slideshow.macroEnabled.12 |
ppsx |
application/vnd.openxmlformats-officedocument.presentationml.slideshow |
pptm |
application/vnd.ms-powerpoint.presentation.macroEnabled.12 |
pptx |
application/vnd.openxmlformats-officedocument.presentationml.presentation |
xlsb |
application/vnd.ms-excel.sheet.binary.macroEnabled.12 |
xlsm |
application/vnd.ms-excel.sheet.macroEnabled.12 |
xlsx |
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
xps |
application/vnd.ms-xpsdocument |
Regards,
ZhiXing Lv from APGC DSI Team
Comments
- Anonymous
February 09, 2015
Hi the information on this blog is just amazing it keeps me coming back time and time again ,personally i met my wife using this site so i couldnt like it any more i have done my best to promote this blog as i know that others need to read this thing ,Thanks for all your effort spent in making this fabulous resource ! ok,nice one Jake - Anonymous
February 14, 2015
Hey there I am so glad I found your site, I really found you by accident, while I was researching on Aol for something else, Anyhow I am here now and would just like to say thanks for a tremendous post and a all round thrilling blog (I also love the theme/design), I don’t have time to read through it all at the minute but I have book-marked it and also added in your RSS feeds, so when I have time I will be back to read a lot more, Please do keep up the fantastic work. - Anonymous
April 09, 2015
If the issue is with IE6, 7, 8, that is the root cause not the trigger of specific file types. As for resolution, these workarounds you listed are potentially workable but why is Microsoft not fixing the IE bug? - Anonymous
April 28, 2015
Hi, is it possible that it also happens in later versions of IE?Greetings Mark - Anonymous
July 01, 2015
I have this problem with a server I use and have checked the MIME types, which match what you have listed above. However whenever anyone tries to click on the link to the files, IE8 still presents them with a zip file. Any other suggestions?