iis7 default mime type behavior

2020-04-08 11:23发布

So in IIS 7 if there is no specific MIME definition for a certain extension, it will refuse to serve it (404) even if you can see it in a directory listing. I'm sure this is a fairly known issue, but is there a way to wildcard or set a default action for unknown file types? I want everything to be offered for download by default like with every other webserver I've used.

3条回答
【Aperson】
2楼-- · 2020-04-08 12:05

Add a new MIME type for files of extension * with a type of application/octet-stream. This will provide a default MIME type for all files that don't have one and bypass the blocking.

The risk, however, is you end up sharing your confidential database, configuration files and whatnot, so make sure you know what you are doing before you open your server to all downloads.

查看更多
我只想做你的唯一
3楼-- · 2020-04-08 12:08

+1 @H2Professor

But here's the code (in this case web.config for IIS 7+):

<configuration>
  <system.webServer>
    <staticContent>
      <mimeMap fileExtension="*" mimeType="application/octet-stream" />
    </staticContent>
  </system.webServer>
</configuration> 
查看更多
男人必须洒脱
4楼-- · 2020-04-08 12:24

I believe you just need to edit your website in Internet Information Services Manager and double click the Request Filtering icon and edit it however you like there.

The mime type configuration does not allow/disallow downloading files; it just tells IIS what to throw in the header when you do download it.

查看更多
登录 后发表回答