How to serve static .json files from a Windows Azure Website

If you upload a .json file to your Windows Azure website and try to access it, it would give you a 404 File Not Found error, because the MIME Type of .json is not set by default. This also applies in general to any file that might need a specific MIME Type.

To fix this issue, FTP into your website and upload the following Web.config file which will set the correct MIME types. If you already have a Web.config file in place, just add the below to the appropriate section.

<?xml version="1.0"?>
            <mimeMap fileExtension=".json" mimeType="application/json" />
Comments (4)
  1. John-GTUC says:

    The solution to my problem. Thank you.

  2. Nivesh Singh says:

    If we are using Node.js on server side better update with:



       <!– indicates that the app.js file is a node.js application

       to be handled by the iisnode module –>


         <add name="iisnode" path="app.js" verb="*" modules="iisnode" />



     &nbsp; &nbsp; &nbsp;&lt;rules&gt;
             &lt;rule name=&quot;DynamicContent&quot;&gt;
         &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;conditions&gt;
         &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;add input=&quot;{REQUEST_FILENAME}&quot; matchType=&quot;IsFile&quot; negate=&quot;True&quot;/&gt;
         &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/conditions&gt;
         &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;action type=&quot;Rewrite&quot; url=&quot;app.js&quot;/&gt;
         &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/rule&gt;
     &nbsp; &nbsp; &lt;/rules&gt;
     &lt;/rewrite&gt; &nbsp; &nbsp;



  3. Mike Rouse says:

    This solution works in that it gets my site working in Azure, but it breaks it completely when I then try to run the site on my local IIS.

  4. GLE says:

    This is a very unsafe way of doing this as you do not control the web server that hosts your website.

    You HAVE to add the following:

    <remove fileExtension=".json" />

    Just before

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

Comments are closed.

Skip to main content