Downloading Docx from IE - Setting MIME Types in IIS

前端 未结 4 1745
滥情空心
滥情空心 2020-11-29 05:37

I am sure there is a simple answer to this one.

I have a docx file that I get an error when trying to download(document cannot be found).... .doc is fine .txt is als

4条回答
  •  情深已故
    2020-11-29 06:29

    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.

提交回复
热议问题