Share via


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"?>
 
<configuration>
    <system.webServer>
        <staticContent>
            <mimeMap fileExtension=".json" mimeType="application/json" />
     </staticContent>
    </system.webServer>
</configuration> 

Download Web.config

Note: This post is cross posted to my new blog at https://sabbour.me/

Comments

  • Anonymous
    June 08, 2013
    The solution to my problem. Thank you.
  • Anonymous
    August 18, 2013
    If we are using Node.js on server side better update with:<configuration> <system.webServer>   <!-- indicates that the app.js file is a node.js application   to be handled by the iisnode module -->   <handlers>     <add name="iisnode" path="app.js" verb="*" modules="iisnode" />   </handlers>     <rewrite>
     &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;
     </system.webServer></configuration>
  • Anonymous
    April 13, 2015
    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.
  • Anonymous
    November 02, 2015
    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" />