I'm serving .JSON files, but even though the file exist, IIS keeps throwing 404 error when any of the file is accessed. I tried renaming one of the file to .JS, and it works.
Any pointer what setting can cause this issue?
By default, IIS in W2K3 and above won't serve files that aren't of a MIME type that it knows about (instead returning 404 errors).
You need to add a MIME type to IIS to allow it to serve that type of file. You can set it at the site level or at the server level.
To set this for the entire server:
I had the same problem. IIS does something called MIME type filtering. If it dosn't know a specific file extension's MIME type, it returns a 404 error.
On IIS <7: Open the site (or server) properties. Click on the HTTP-Header tab. Click on the MIME Types button. Add the file type * with the MIME type "application/octet-stream".
For IIS 7: Open IIS manager. Click the server or website. Double-click the MIME Types feature icon. In the Actions pane, click Add. Populate the "File Name Extension" box with * and the MIME Type box with "application/octet-stream".
I added MIME type
text/json to the site in IIS to view in browser as text.
To consolidate answers into one more general answer:
Here comes the caveat:
If you're experiencing this sort of problem, open up the website's web log files, and have a look at the sub-status code (i.e. 404 3) to determine exactly why your website isn't serving content for IIS 6, or
in IIS 7.
I had this problem too - and the problem turned out to be file permissions on the folder where the json file was stored. I answered a similar question here.
These folks are all correct to say you need to add the MIME type.
The MIME type enables the file extension on the server and the Mapping Handler tells IIS what to do with it.
Add a Script Map
JSON(you can call it anything you like)