user441521
user441521

Reputation: 6998

404 Not Found when I look for .json file in ASP.NET MVC app

My ASP.NET MVC 5 app can't find json files. I'm getting a 404 error when I look for a json file, but if I look for a png file in the same directory it finds that. In web.config I have:

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

Is there anything else I need to do in Visual Studio to find json files?

Upvotes: 13

Views: 11111

Answers (2)

Raja Nadar
Raja Nadar

Reputation: 9489

<system.webServer>
 <staticContent>
  <mimeMap fileExtension=".json" mimeType="application/json; charset=UTF-8" />
 </staticContent>
</system.webServer>

See adding .json handler support in IIS.

Also, ensure the request is not going into the routing framework by putting a breakpoint. (since PNG is served, this is probably not an issue)

Upvotes: 30

mnsr
mnsr

Reputation: 12437

You need to go into IIS and add a mimetype for it as well as adding it into your web.config file.

Upvotes: 3

Related Questions