Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Downloading Docx from IE - Setting MIME Types in IIS

Tags:

mime-types

iis

People also ask

Which MIME type is default MIME type present in IIS?

MIME types help clients handle new file name extensions appropriately. If IIS does not recognize the file name extension requested by the client, IIS sends the content as the default MIME type, which is Application.

Where is MIME Types IIS?

In IIS Manager, right-click the local computer, and click Properties. Click the MIME Types button.


Yes, it's just an IIS setting: by default, it will only serve files for which the extension matches a defined MIME type.

To allow .docx files to be downloaded, follow the steps from the KB article linked above:

  1. Open the IIS Microsoft Management Console (MMC), right-click the local computer name, and then click Properties.
  2. Click MIME Types.
  3. Click New.
  4. In the Extension box, type the file name extension that you want (in this case, .docx).
  5. In the MIME Type box, type application/vnd.openxmlformats-officedocument.wordprocessingml.document (thanks to @web developer for pointing out this MIME type, which supercedes the 'application/msword' from my original answer).
  6. Apply the new settings. Note that you must restart the World Wide Web Publishing Service or wait for the worker process to recycle for the changes to take effect. In this example, IIS now serves files with the .docx extension.

Note that the KB article uses the generic application/octet-stream MIME type: although that generally should work, if a more specific MIME type exists, such as application/msword, it's always best to use that.


In step 5 of the solution above you said

In the MIME Type box, type application/msword.

The "application/msword" MIME type is the type for the word 2003 ".doc" files. The correct MIME type for word 2007 ".docx" files is:

application/vnd.openxmlformats-officedocument.wordprocessingml.document

See this post.


Thanks this is very useful.

If you are interested MIME type for .pptx (Powerpoint 2007) is

application/vnd.openxmlformats-officedocument.presentationml.presentation

and .xlsx (Excel 2007) is

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

[These where transposed. I have corrected now, thanks for pointing it out Sven.]


When there is no mime type associated with an extension in IIS (6.0 and up), it will give you 404. See Requests for static files return 404 error (IIS 6.0). (Edit: The original MSDN link is dead as of mid-2017, the Internet Archive has a copy. Even though it was written for IIS6, the information still applies to modern IIS versions.)

Other than that, and just because you did not specify where the error shows up: When you forbid caching in a header, similar behavior may occur on the client. But that is a general issue, and not bound to .docx.