IIS Web.config - 确保检测到没有文件扩展名的文件

IIS Web.config - Ensure Detection of Files with No File Extensions

我正在尝试通过将文件发布到我的域来执行验证过程。然后,从公司管理门户,我应该能够浏览到该文件并完成验证过程。它失败是因为我的站点 returns 出现 404 错误,指出资源不存在,而实际上它确实存在。如何让我的 web.config 识别对没有文件扩展名的文件的请求?!

在我的 web.config 中,但这不起作用:

`<configuration>
     <system.webServer>
        <staticContent>
           <mimeMap fileExtension="*" mimeType="text/plain" />
        </staticContent>
                              .
                              . 
                              .`

@LexLi,回答了这个问题!这是我更新 web.config 文件的方式(如下)。

`<configuration>
     <system.webServer>
        <staticContent>
           <mimeMap fileExtension="." mimeType="text/plain" />
        </staticContent>
                              .
                              . 
                              .`

从评论中复制。

对于没有扩展名的文件,您必须在 mimeMap 标签中使用 . 作为 fileExtension

2009年写the blog post时,我在微软工作,我的同事查看了IIS的源代码以确认这一点。遗憾的是,它从未成为官方文档的一部分,因此即使在 2009 年之后,也有大量关于如何做的讨论。