I have - again - a problem in my WebAPI application.
I am trying to deploy on different versions of IIS (7, 7.5, 8). Newer versions seem to have a global MIME handler for .json, while older versions don't.
When IIS finds no MIME handler, the file does not exist. So, for the older version I made a local MIME handler in web.config. The tricky part is: if it finds two of them (one global and one local), it stops working - even if they both are the same, IIS does not know which one to choose (wtf!?) and only throws errors.
Is there a switch I can apply in web.config which states that the MIME is only to be used if there is no other MIME for this extension available?
If not, can I tell VisualStudio to deploy different versions of web.config, depending on the deployment profile - and/or can I apply a IIS-version-based switch in web.config?
The easiest way to deal with this is to use the remove option for a mime mapping like this:
<system.webServer>
...
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
</staticContent>
</system.webServer>
It's discussed in detail 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
There's also a reference to it here: Add MIME mapping in web.config for IIS Express
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With