Svg is not rendered, the browser downloads the file in iis

2

When you access the site containing an svg image, it does not appear but the browser downloads the image and the following message appears in the debug console:

Resource interpreted as Document but transferred with MIME type application / octet-stream:

The server is from localweb and it is iis, the site is developed in asp. in html is as follows:

<object id="imgSvg" data="map.svg" type="image/svg+xml"></object>

What could be wrong?!

    
asked by anonymous 10.07.2014 / 15:11

1 answer

2

Every time IIS receives a request, it gets the requested resource (a page, image, etc.) and returns it on the HTTP channel. Imagine that the IIS response is delivered to the browser inside an "envelope", and that in the header of that envelope there is a lot of extra information in addition to what you requested. One such information is the type of content inside the envelope.

The browser uses this information to decide how to open the content. If IIS says an image is a page, the browser will try to open it as a page, and vice versa.

What happens in your case is that IIS does not know what SVG is, so it sends it as the default type of it, which is application. This always forces the download.

To resolve, you need to add the SVG type in the IIS MIME type dictionary. Here's the official documentation on how to do this: link

And in case the link breaks one day:

  

Open IIS Manager and navigate to the level you want to manage. (...).

     
  • In Features View, double-click MIME Types.
  •   
  • In the Actions pane, click Add.
  •   
  • In the Add MIME Type dialog box, type a file name extension in the File Name Extension text box. For example, type .xyz.
  •   
  • Type a MIME type in the MIME Type text box. Type, for example, application / octet-stream.
  •   
  • Click OK.
  •   

Just replace .xyz with .svg. And do not use application/octet-stream , this is what forces downloads. Use image/svg+xml instead.

    
10.07.2014 / 15:24