错误 404.3 未找到 JSON 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15944311/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ERROR 404.3 Not Found for JSON file
提问by Nitin Suri
I have been getting the "ERROR 404.3 Not Found" for JSON file that I am calling using AJAX call on "Internet Information Services 7.5" even after I have activated all the "Application Development Features". Other than JSON file, all other files are getting loaded.
即使在我激活了所有“应用程序开发功能”之后,我还是在“Internet 信息服务 7.5”上使用 AJAX 调用来调用 JSON 文件的“错误 404.3 未找到”。除了 JSON 文件,所有其他文件都被加载。
I am running an HTML page on IIS server on my local machine.
我在本地机器上的 IIS 服务器上运行 HTML 页面。
If I open the file directly then there is no problem at all. When I host the files on an online server it works fine.
如果我直接打开文件,则完全没有问题。当我将文件托管在在线服务器上时,它工作正常。
Any quick help will be much appreciated.
任何快速帮助将不胜感激。
采纳答案by elasticman
Is the file you try to receive in the same domain? Or do you fetch the json from another server? If it is hosted on a different domain, you'll have to use JSONP due to same origin policy.
您尝试接收的文件是否在同一个域中?或者你从另一台服务器获取json?如果它托管在不同的域上,由于同源策略,您将不得不使用 JSONP。
回答by Himanshu
As suggested by @ancajic i put the below code after connectionString tag in my web.config file and it worked.
正如@ancajic 所建议的,我将下面的代码放在我的 web.config 文件中的 connectionString 标记之后,并且它起作用了。
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
回答by ancajic
As said by @elasticman, it is necessary to open IIS Manager -> Mime types -> Add a new mime type with
正如@elasticman 所说,有必要打开 IIS Manager -> Mime types -> Add a new mime type with
Extension: .json MIME Type: application/json
扩展名:.json MIME 类型:application/json
But for me that still wasn't enough. I have an ASP.NET MVC 4 application, and I had to modify my root Web.configfile.
但对我来说,这还不够。我有一个 ASP.NET MVC 4 应用程序,我不得不修改我的根Web.config文件。
Insert
插入
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
somewhere inside your
在你的某处
<system.webServer>
...
</system.webServer>
回答by xqzh76
If you are using IIS Express with Visual Studio, IIS Manager won't work for IIS Express. Instead, you need to open this config file from %userprofile%\documents\IISExpress\config\applicationhost.config and insert
如果您在 Visual Studio 中使用 IIS Express,IIS 管理器将不适用于 IIS Express。相反,您需要从 %userprofile%\documents\IISExpress\config\applicationhost.config 打开这个配置文件并插入
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
along with all other pre-defined mime types.
以及所有其他预定义的 mime 类型。
回答by Udara Kasun
Option 1
选项1
Go to IIs
Select Website
Double Click Mime Type Icon Under IIs
Click Add Link in right hand side
File Name Extension = .json Mime Type = application/json
Click Ok.
转到 II
选择网站
双击 IIs 下的 Mime Type 图标
点击右侧的添加链接
文件扩展名 = .json Mime 类型 = application/json
单击确定。
Option 2
选项 2
Update your web.config file like this
像这样更新你的 web.config 文件
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
I hope your problem is resolved
我希望你的问题得到解决
回答by RasoolLotfi
I've applied the following settings on the IIS was right.
我在 IIS 上应用了以下设置是正确的。
1.Open IIS Manager
1.打开IIS管理器
2.Display properties for the IIS Server
2.显示IIS服务器的属性
3.Click MIME Types and then add the JSON extension:
3.单击 MIME 类型,然后添加 JSON 扩展名:
File name extension: .json
文件扩展名:.json
MIME type: application/json
MIME 类型:应用程序/json
4.Go back to the properties for IIS Server
4.回到IIS服务器的属性
5.Click on Handler Mappings
5.单击处理程序映射
Add a script map
添加脚本映射
Request path: *.json
请求路径:*.json
Executable: C:\WINDOWS\system32\inetsrv\asp.dll Name: JSON
可执行文件:C:\WINDOWS\system32\inetsrv\asp.dll 名称:JSON
回答by Antonio Garcia Marin
I haven't the same problem but for me (Windows Server 2003 IIS 6) the MIME type application/json not work. I use text/plain and work perfect (You not need restart the server)
我没有同样的问题,但对我(Windows Server 2003 IIS 6)来说,MIME 类型的应用程序/json 不起作用。我使用 text/plain 并且工作完美(您不需要重新启动服务器)
回答by BadHeuristics
To solve this problem with an Azure App Service:
要使用 Azure 应用服务解决此问题:
Use FTP or the Kudu dashboard to add this file one level above wwwroot--
使用 FTP 或 Kudu 仪表板将此文件添加到 wwwroot 上一级 -
/site/applicationHost.xdt:
/site/applicationHost.xdt:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" xdt:Transform="InsertBefore(/configuration/system.webServer/staticContent/*[1])" />
</staticContent>
</system.webServer>
</configuration>
Then, under Application settings in the Azure Portal, add a Handler mapping:
然后,在 Azure 门户中的应用程序设置下,添加一个处理程序映射:
.json C:\WINDOWS\system32\inetsrv\asp.dll

