Reputation: 2386
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 its already included. Removing the remote IIS mimeType is not practical in this particular case. I end up using a different web.config
Is there another mechanism by which I can configure Azure IIS mimeType so I don't have this problematic web.config?
I would like a single deployment package that will work on Azure and non Azure.
Upvotes: 8
Views: 6799
Reputation: 11294
This should work:
<system.webServer>
<staticContent>
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
This doesn't make any difference to your overall IIS configuration, it just conditionally removes the mimeMap from the configuration of this particular site (as governed by this web.config
) before adding it again.
Upvotes: 20
Reputation: 24895
You can create a startup task that adds the mime type on IIS level. This way you won't 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
Upvotes: 3