无法通过Classic ASP中的URL访问JSON文件

时间:2017-08-16 18:47:19

标签: json vbscript asp-classic

我正在使用经典的ASP网站。目前,要使用DataTables.js运行一些测试,我已经设置了一个包含以下代码的基本json文件:

{
  "draw": 1,
  "recordsTotal": 57,
  "recordsFiltered": 57,
  "data": [
    [
      "Airi",
      "Satou",
      "Accountant",
      "Tokyo",
      "28th Nov 08",
      "$162,700"
    ],
    [
      "Angelica",
      "Ramos",
      "Chief Executive Officer (CEO)",
      "London",
      "9th Oct 09",
      "$1,200,000"
    ],
    [
      "Ashton",
      "Cox",
      "Junior Technical Author",
      "San Francisco",
      "12th Jan 09",
      "$86,000"
    ],
    [
      "Bradley",
      "Greer",
      "Software Engineer",
      "London",
      "13th Oct 12",
      "$132,000"
    ],
    [
      "Brenden",
      "Wagner",
      "Software Engineer",
      "San Francisco",
      "7th Jun 11",
      "$206,850"
    ],
    [
      "Brielle",
      "Williamson",
      "Integration Specialist",
      "New York",
      "2nd Dec 12",
      "$372,000"
    ],
    [
      "Bruno",
      "Nash",
      "Software Engineer",
      "London",
      "3rd May 11",
      "$163,500"
    ],
    [
      "Caesar",
      "Vance",
      "Pre-Sales Support",
      "New York",
      "12th Dec 11",
      "$106,450"
    ],
    [
      "Cara",
      "Stevens",
      "Sales Assistant",
      "New York",
      "6th Dec 11",
      "$145,600"
    ],
    [
      "Cedric",
      "Kelly",
      "Senior Javascript Developer",
      "Edinburgh",
      "29th Mar 12",
      "$433,060"
    ]
  ]
}

该表给出了在找不到文件时发生的经典AJAX错误警告。经过进一步检查,我发现如果我尝试访问url中的JSON文件它显示为404,我知道该文件在那里,因为如果我在test.asp的同一文件夹中发布一个类似的文件:

<%
  Response.Write("Test test")
%>

并导航到将example.json交换为test.asp的相同路径我在浏览器中显示正确的"Test test"

json需要显示特殊配置吗?如果我在我的机器中使用IIS管理器本地运行它并转到它将显示的文件,但它不会显示在服务器中的应用程序内。我很困惑为什么这个问题只出现在服务器中。缺少配置可能吗?

1 个答案:

答案 0 :(得分:3)

我在这里遗漏了一些数据,所以我会做出一些假设。

如果您使用安装了请求过滤的IIS(通常是这样),听起来似乎不允许IIS提供文件扩展名。

要解析打开IIS管理器&gt;选择您的网站&gt;请求过滤&gt;文件名扩展名(选项卡),并确保.json存在并且&#34;允许&#34; =真。