1

Using IIS in Windows server 2016, files with the extension .txt are not served.

The resulting status code is 403, access denied.

Why?

The mime type .txt is listed in the server root with the mime type text/plain. The default web site inherits it (together with every other mime type). No override seems to be made when it comes to mime types.

I can add another mime type, put a file with the new (made up) extension and have it served as a text file.

I tried to remove the mime type and add it again (not using period before the suffix name).

No other file type seems to cause problems. It is just txt files, I even have support for php on the server.

edit

In a comment, I was asked about which substatus error code I was getting. The log file shows lines like this:

2017-05-08 00:54:17 172.31.14.247 GET /foobar/1.txt - 80 - 2.94.45.4 Mozilla/3.0+(compatible;+Indy+Library) - 403 1 5 64

so the answer would be 403.1 (execute access forbidden). Is the IIS trying to execute txt-files?

3
  • 1
    what is the sub-status of your 403? check your IIS http logs. May 8, 2017 at 8:44
  • Seems to be 403.1, question updated. May 8, 2017 at 13:02
  • 1
    You should not get a 403.1 for a *.txt file, something is wrong with your configuration. Enable Failed Request tracing to find out what modules or handlers are running for the request. May 8, 2017 at 14:13

1 Answer 1

3

Instead of IIS > MIME Types, revise IIS > Handler Mappings. There shouldn't be any (script) Handler associated with Path *.txt, but it should have (or fall back to "Static File" *):

  • Path Type: File or Folder
  • Module: StaticFileModule,DefaultDocumentModule,DirectoryListingModule
  • In Request Restrictions, Verbs: All, Access: Read.

(IIS 7 documentation is up-to-date: the handlers element was not modified in IIS 10/8.5/8.0/7.5/7.0).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .