【问题标题】:Why does StaticFileHandler not server .json?为什么 StaticFileHandler 不是服务器 .json?
【发布时间】:2014-02-05 17:03:14
【问题描述】:

我们通过 IIS7.5 下载 .json 文件时遇到问题。

MIME 类型已正确设置:

 <mimeMap fileExtension=".json " mimeType="application/json" />

但仍然报错:“HTTP Error 404.3 - Not Found”。

要让它工作,我们必须添加一个处理程序映射:

<handlers>
    <add name="JSON" path="*.json" verb="*" modules="IsapiModule" scriptProcessor="C:\WINDOWS\system32\inetsrv\asp.dll" resourceType="Unspecified" />
</handlers>

为什么 json 文件不能像其他静态内容一样被 StaticFileHandler 处理?看起来很奇怪,我们必须安装经典的 asp 支持来处理 json 文件。

【问题讨论】:

    标签: json iis-7.5


    【解决方案1】:

    在我的例子中,StaticFileHandler 自己处理 json。不需要 asp.dll 处理程序。

    问题是 fileExtension 属性中的一个偷偷摸摸的尾随空格:

    <mimeMap fileExtension=".json " mimeType="application/json" />
    

    呵呵

    【讨论】:

    • 即使你想部署它?
    【解决方案2】:

    最近我也遇到了这个问题。首先我added the .json MIME type。但我已将我的 json 文件放在 app_data 文件夹中。如果您不授予 Web 应用程序对该文件夹的权限,它将无法工作。

    尝试将您的 json 文件与 html 文件放在同一文件夹中。

    此外,除非您有 installed the Classic Asp module(在 Windows 功能中),否则映射处理程序将无法工作。我写了some full directions here

    【讨论】:

    • 感谢您的回答,它促使我再次审查。我实际上是在问为什么需要添加处理程序 - staticfilehandler 应该能够提供 json。我现在设法发现了我的问题,对我来说,现在不需要经典的 asp 模块。
    猜你喜欢
    • 2011-05-27
    • 1970-01-01
    • 2015-07-22
    • 2017-05-21
    • 2012-06-01
    • 2018-01-05
    • 1970-01-01
    • 1970-01-01
    • 2013-05-14
    相关资源
    最近更新 更多