3

I have a asp.net project with a html file(Html 5). I am trying to set the SVG as background of my body tag using the CSS 3. I have my file like this.

enter image description here

In my Style.css.

enter image description here

when i double click and open the html file. i can see the body filled with SVG, but this is not working when i debug with VS 2010.

This is what i got when i debug the html using the vs 2010.

enter image description here

Is any thing i missed here ? how to fix this ?

Michael Mullany
  • 30,283
  • 6
  • 81
  • 105
BalaKrishnan웃
  • 4,337
  • 7
  • 30
  • 51

2 Answers2

8

My workaround for this was to create my own httphandler locally which overwrote the content-type for svg.

public class SvgHandler : IHttpHandler
{

    public bool IsReusable
    {
        get { return false; }
    }

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "image/svg+xml";
        context.Response.BinaryWrite(File.ReadAllBytes(context.Request.PhysicalPath));
        context.Response.End();
    }
}

and in web.config i added:

<httpHandlers>
  <add verb="*" path="*.svg" type="SvgHandler" />
</httpHandlers>

with this solution you don't have to use IIS express, you can just use the regular development server in visual studio 2010

Robin Karlsson
  • 797
  • 1
  • 7
  • 11
5

The built-in Visual Studio web server only has a limited set of mime-types it can serve. SVG is not one of them.

See here for a concise answer: https://serverfault.com/questions/359904/how-to-configure-iis-for-svg-and-web-testing-with-visual-studio

Community
  • 1
  • 1
Jay
  • 884
  • 11
  • 16