53

Does anyone know if it is possible to add the SVG mime type to a Windows Azure Website? I tried with a web.config file but that only broke my website.

Is this a limitation of the current preview or am I missing something?

thanks for your help!

cmplieger
  • 7,155
  • 15
  • 55
  • 83

2 Answers2

105

What you can do in Windows Azure Websites (on web.config level) is pretty limited, but you should be allowed to add the mime type under staticContent:

<configuration>
   <system.webServer>
      <staticContent>
         <remove fileExtension=".svg"/>
         <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
      </staticContent>
   </system.webServer>
</configuration>
Amadeusz Wieczorek
  • 3,139
  • 2
  • 28
  • 32
Sandrino Di Mattia
  • 24,739
  • 2
  • 60
  • 65
  • 2
    This works! I already tried something like this before but I guess I did it wrong. Thanks! – cmplieger Aug 07 '12 at 13:39
  • 1
    @SnippetSpace - I've had the experience where adding a `` to an Azure website that the Azure web server already supports can break the website. That might be what you ran into before. – Ken Smith Jan 12 '13 at 06:54
  • 10
    It's important to remove the existing registration first to have it work local. Like the example here http://odetocode.com/blogs/scott/archive/2012/08/07/configuration-tips-for-asp-net-mvc-4-on-a-windows.aspx – Rasmus Christensen Jan 04 '14 at 23:58
  • Thanks Sandrino and @Rasmus. Worked a treat! – Jonathan Jul 29 '14 at 05:52
  • 4
    I had to add a `` *before* the `` to make it work on my machine. – Bart Verkoeijen Aug 20 '14 at 09:38
  • I wasn't able to find this anywhere, but you can simply put file a called `web.config` in the root of your repository with the content shown above. Then `.svg`-files should work – it did on my Azure Web App. – qff May 11 '15 at 13:43
  • Works as expected. Big relief after updateing my webapp and seeing it didn't get the .svg file with a 404 altough it was published, phew...thanks a lot! – Youp Bernoulli May 22 '15 at 11:48
3

Others like me may have reached here having the same problem not resolved because of other related file types, in my case I also needed .eot and .woff mime mappings.

<system.webServer>
    <staticContent>
        <remove fileExtension=".svg" />
        <remove fileExtension=".eot" />
        <remove fileExtension=".woff" />
        <mimeMap fileExtension=".svg" mimeType="image/svg+xml"  />
        <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
        <mimeMap fileExtension=".woff" mimeType="application/x-woff" />
    </staticContent>
</system.webServer>
Venkataraman R
  • 12,181
  • 2
  • 31
  • 58
ahmad bd
  • 53
  • 6