HTML5 MIME types on IIS 8

If you have a website that uses HTML5 file types, and you run the site on IIS 7/7.5, you have to manually add the special file extensions in the IIS MIME Types list to make sure the webserver allows the clients to access them. You can add something like this to your web.config:

  <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
  <mimeMap fileExtension=".m4v" mimeType="video/m4v" />
  <mimeMap fileExtension=".ogg" mimeType="video/ogg" />
  <mimeMap fileExtension=".ogv" mimeType="video/ogg" />
  <mimeMap fileExtension=".webm" mimeType="video/webm" />
  <mimeMap fileExtension=".oga" mimeType="audio/ogg" />
  <mimeMap fileExtension=".spx" mimeType="audio/ogg" />
  <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
  <mimeMap fileExtension=".svgz" mimeType="image/svg+xml" />
  <remove fileExtension=".eot" />
  <mimeMap fileExtension=".eot" mimeType="application/" />
  <mimeMap fileExtension=".otf" mimeType="font/otf" />
  <mimeMap fileExtension=".woff" mimeType="font/x-woff" />

However, when you upgrade your server and move your site to IIS 8, then you’ll get a nice 500.19 Internal Server Error.


If you enable detailed error messages, you can see that the error is in the mimeMap section of the web.config file:

Cannot add duplicate collection entry of type ‘mimeMap’ with unique key attribute ‘fileExtension’ set to ‘.m4v’

The root of the problem is, that IIS 8 supports the most widely used MIME types out of the box, and they are registered at the server level, therefore all websites inherit them.

The solution is to get rid of the manual registration from your web.config file. In my case, I had to remove the following extensions:

mp4, m4v, m4a, ogv, oga, ogg, webm, spx, svg, svgz, otf, woff

Please don’t forget to update your installers and setup scripts!


Technorati-címkék: ,,

3 thoughts on “HTML5 MIME types on IIS 8

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s