Adding support for SVG to IIS Express

I’m currently building a HTML 5 website, using Microsoft’s as inspiration.

Taking inspiration sometimes means “borrowing” some of the graphics and styles on a site you like and incorporating them into your own work. For the purposes of education, this isn’t always a bad thing.

One of the things I borrowed was a rather nice SVG background image, that sort of looks like glass. I just downloaded that image and added into my MVC project. The thing was, that no matter what CSS I tried, I couldn’t get the image to actually display. Some investigation into the issue revealed that IIS Express is configured not to actually server SVG files. It returns HTTP 403 status code.

In order to add support for SVG, the MIME type must be added to the IIS Express configuration. Thankfully, this is easy.

  • Open a console application with administrator privilages.
  • Navigation to the IIS Express directory. This lives under Program Files or Program Files (x86)
  • Run the command appcmd set config /section:staticContent /+[fileExtension=’svg’,mimeType=’image/svg+xml’]

This will add the necessary MIME extension to IIS so it will serve SVG files without issue.