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