How to allow download of .json file with ASP.NET

Lea Hayes picture Lea Hayes · Nov 16, 2011 · Viewed 109k times · Source

How can I enable the download of *.json files from an old ASP.NET site (IIS6 I am led to believe)?

I am getting a 404 page instead of the JSON file.

Do I need to create a web.config file? What goes in it?

Answer

ProVega picture ProVega · May 13, 2012

If you want to manually add support to your site, you can just add the following to your web.config in the system.webServer section:

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

This will add a "local" configuration under IIS. This does not work in IIS6, but does work in IIS7 and newer.