HTML5 and CSS3 introduces some new file types that enables us to create even better websites. We are now able to embed video, audio and custom fonts natively to any web page. Some of these file types are relatively new and not supported by the IIS web server by default. It’s file types like .m4v, .webm and .woff.

When a request is made to the IIS for these unsupported file types, we are met with the following error message:

HTTP Error 404.3 - Not Found

The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

The problem is that the IIS doesn’t know how to serve these new files unless we tell it how. This can be easily done in the web.config’s <system.webServer> section by adding the following snippet:

    <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" />

The above snippet includes support for most video, audio and font file types used by HTML5 and CSS3.


Eric Flamm

Mads - thanks for the snippet. But does this work with websites? I've got a demo site on Azure that won't render svg images because it thinks they're (default - html/text). I tried adding this web.config, but it just broke the site entirely. &lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;configuration&gt; &lt;system.webServer&gt; &lt;staticContent&gt; &lt;remove fileExtension=".svg&gt; /&gt; &lt;mimeMap fileExtension=".svg" mimeType="image/svg xml" /&gt; &lt;/staticContent&gt; &lt;/system.webServer&gt; &lt;/configuration&gt;

Eric Flamm
Eric Flamm

Oops - found it - there's a "&gt;" where there should be a """. Guess I'm a bit spoiled by the VS syntax checker...

Eric Flamm

Says for fileExtension=".woff" it sould be "application/font-woff"

Vitor Canova

Didn't know you could set MIME directly on Web.config.

Vitor Canova

just in case I would always remove fileExtension before adding it.


Comments are closed