user441521 user441521 - 17 days ago 5
ASP.NET (C#) Question

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?

Answer
<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)

Comments