You are here

Viewing SVG and other HTML5 content when debugging in Visual Studio


When working on modern web applications that use features that are recently supported by browsers such as SVG, you may find that images do not render correctly, or at all in the browser.


When most of use develop and test web applications locally, we use the built-in web server, called ASP.NET Development Server/ This works fine for testing, and most applications will eventually get deployed to a web server running IIS 7.0 or later.

The Problem

The ASP.NET Development Server is not aware that it should serve SVG with a MIME content-type of [geshifilter-code]image/svg[/geshifilter-code]. Instead it uses the generic [geshifilter-code]application/octet-stream[/geshifilter-code]. A modern web browser on the other hand will typically either request [geshifilter-code]image/*[/geshifilter-code] or explicitly request [geshifilter-code]image/svg+xml[/geshifilter-code]. If the response is [geshifilter-code]application/octet-stream[/geshifilter-code], it will ignore the response (tested in IE9, FF14).

The usual way of fixing this is to add this code block to web.config:

Unfortunately ASP.NET Development Server is unable to understand this directive.

To workaround this problem, install and use IIS 7.5 Express to serve the content locally. This will require instructing Visual Studio to use IIS instead.


Add new comment

Simple Copyright Policy: If you want to reproduce anything on this site, get my permission first.