Azure and .json mimeType without web.config

Adding to my web.config

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

Allows my application to run on Azure, but will crash my remote IIS server because it is already on. Removing the remote IIS mimeType in this particular case is impractical. I end up using a different web.config

Is there another mechanism with which I can configure mimeType Azure IIS so that I don't have this problematic web.config?

I need a deployment package that will run on Azure and not Azure.

+7
source share
2 answers

This should work:

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

See also here: http://blogs.msdn.com/b/chaun/archive/2009/12/04/iis7-error-cannot-add-duplicate-collection-entry-of-type-mimemap-with-unique -key-attribute-fileextension.aspx

It doesn't make any difference to your overall IIS configuration, it only conditionally removes the mimeMap from the configuration of this particular site (as described in this web.config ) before adding it again.

+16
source

You can create a launch task that adds the mime type at the IIS level. This way you do not need to include it in your web.config:

 "%windir%\System32\inetsrv\appcmd.exe" set config /section:staticContent /+"[fileExtension='.json',mimeType='application/json']" exit /b 0 
+3
source

All Articles