ERROR 404.3 Not Found for JSON file

2019-01-16 17:51发布

问题:

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.

I am running an HTML page on IIS server on my local machine.

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.

回答1:

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.



回答2:

As suggested by @ancajic i put the below code after connectionString tag in my web.config file and it worked.

  <system.webServer>
    <staticContent>
      <mimeMap fileExtension=".json" mimeType="application/json" />
    </staticContent>
  </system.webServer>


回答3:

As said by @elasticman, it is necessary to open IIS Manager -> Mime types -> Add a new mime type with

Extension: .json MIME Type: 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.config file.

Insert

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

somewhere inside your

<system.webServer>
    ...
</system.webServer>


回答4:

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

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

along with all other pre-defined mime types.



回答5:

I've applied the following settings on the IIS was right.


1.Open IIS Manager

2.Display properties for the IIS Server

3.Click MIME Types and then add the JSON extension:

File name extension: .json

MIME type: application/json

4.Go back to the properties for IIS Server

5.Click on Handler Mappings

Add a script map

Request path: *.json

Executable: C:\WINDOWS\system32\inetsrv\asp.dll Name: JSON



回答6:

  1. Go to IIs

  2. Select Website

  3. Double Click Mime Type Icon Under IIs

  4. Click Add Link in right hand side

  5. File Name Extension = .json Mime Type = application/json

  6. Click Ok.

Or update your web.config like this

<system.webServer>
    <staticContent>
      <mimeMap fileExtension=".json" mimeType="application/json" />
    </staticContent>
</system.webServer>

I hope your problem is resolved



回答7:

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)



回答8:

To solve this problem with an Azure App Service:

Use FTP or the Kudu dashboard to add this file one level above wwwroot--

/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:

.json      C:\WINDOWS\system32\inetsrv\asp.dll