2

Posted by Michael Alfaro on October 26, 2011

IIS 7 Web.config change for HTML5 and CSS3 mime types

Needed to add new mime types to an ASP.NET application that will be running on IIS7, and found this great article that sets you up for a bunch of file types that are common to HTML5 and CSS3.  Original Source: http://madskristensen.net/post/Prepare-webconfig-for-HTML5-and-CSS3.aspx

“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:

<staticContent>
    <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/vnd.ms-fontobject" />
    <mimeMap fileExtension=".otf" mimeType="font/otf" />
    <mimeMap fileExtension=".woff" mimeType="font/x-woff" />
</staticContent>

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

Topics: , , ,

Add a Comment



 

Showing 2 Comments

  1. Alex

    Shouldn’t those be image/svg+xml, rather than images/…?

  2. Michael Alfaro

    Alex, you are correct, I’ll adjust the post now, thanks for pointing it out!