在Windows Azure网站中使用SVG

53
有人知道如何将SVG文件类型添加到Windows Azure网站中吗? 我尝试使用web.config文件,但是这只会破坏我的网站。 这是当前预览版的限制还是我漏了什么? 谢谢你的帮助!
3个回答

105

在Windows Azure网站(在web.config级别)中,您可以做的事情非常有限,但是您应该被允许在staticContent下添加mime类型:

<configuration>
   <system.webServer>
      <staticContent>
         <remove fileExtension=".svg"/>
         <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
      </staticContent>
   </system.webServer>
</configuration>

2
这个有效!我以前尝试过类似的东西,但我想我做错了。谢谢! - cmplieger
1
@SnippetSpace - 我曾经有这样的经历,在Azure网站中添加一个Azure Web服务器已经支持的<mimeMap />可能会破坏网站。这可能就是你之前遇到的问题。 - Ken Smith
10
首先需要删除现有的注册信息才能使其在本地运行。可以参考这个例子:http://odetocode.com/blogs/scott/archive/2012/08/07/configuration-tips-for-asp-net-mvc-4-on-a-windows.aspx。 - Rasmus Christensen
感谢Sandrino和@Rasmus。非常有效! - Jonathan
4
在我的机器上使其正常工作,我必须在 <mimeType/> 之前添加一个 <remove fileExtension=".svg"/> - Bart Verkoeijen
显示剩余2条评论

3

像我这样的人可能会因为其他相关文件类型而没有解决同样的问题而到达这里,在我的情况下,我还需要.eot.woff的mime映射。

<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>

0
这是我按照现在使用的新图标标准所做的,你需要从https://www.iana.org/assignments/media-types/media-types.xhtml#font使用的。
<staticContent>
    <remove fileExtension=".svg" />
    <remove fileExtension=".eot" />
    <remove fileExtension=".woff" />
    <remove fileExtension=".woff2" />
    <mimeMap fileExtension=".svg" mimeType="image/svg+xml"  />
    <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
    <mimeMap fileExtension=".woff" mimeType="font/woff" />
    <mimeMap fileExtension=".woff2" mimeType="font/woff2" />
</staticContent>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接