66

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.

Nitin Suri
  • 960
  • 1
  • 8
  • 20

8 Answers8

110

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>
Himanshu
  • 2,251
  • 4
  • 20
  • 25
33

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>
AndroC
  • 4,758
  • 2
  • 46
  • 69
28

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.

elasticman
  • 641
  • 8
  • 20
  • it's the same domain, below is the folder structure: root folder index.html - data/data.json - js/js.js – Nitin Suri Apr 11 '13 at 09:05
  • 70
    Okay, the problem is that IIS has no JSON-File type by default (MIME) so you have to set it up: To set this for the entire server: 1. Open properties for your server in your IIS Manager and go for MIME Types. 2. Use "New" and enter "JSON" as extension and "application/json" for MIME. – elasticman Apr 11 '13 at 12:56
  • 1
    thanks elasticman, iis has no json file type and does not recognise it. – Nitesh Jun 03 '14 at 11:13
12

Option 1

  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.

Option 2

Update your web.config file like this

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

I hope your problem is resolved

Udara Kasun
  • 2,182
  • 18
  • 25
9

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.

xqzh76
  • 91
  • 1
  • 2
6

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

RasoolLotfi
  • 306
  • 3
  • 6
0

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)

0

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
BadHeuristics
  • 319
  • 1
  • 6