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.

7 thoughts on “Adding support for SVG to IIS Express

  1. When I used this, it added svg with a mimeType of “image/svg xml” (note the missing “+”). This caused SVG files to be downloaded rather than displayed in every browser except IE. I manually added the plus and it began working properly for the browsers I’ve tested so far. Hope this helps!

      1. The config file for IIS Express lives in C:Users[username]DocumentsIIS Expressconfig and you can edit the applicationhost.config to manually change the file extensions.

  2. Thank you much. I needed IIS Express to serve up LESS files, and your post pointed me in the right direction.
    appcmd set config /section:staticContent /+[fileExtension=’less’,mimeType=’text/css’]

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.