svg 不适用于本地主机上的 IIS 网络服务器 [英] svg is not working on IIS webserver on localhost

查看:18
本文介绍了svg 不适用于本地主机上的 IIS 网络服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 css 将.svg"图像设置为背景图像,但它不起作用.url 有效并返回 200 状态代码并适用于.png"图像.

I'm trying to set a ".svg" image as background-image using css, but it is not working. The url is valid and returns 200 status code and works on ".png" images.

有什么问题?

推荐答案

您的 IIS 很可能没有配置 SVG 作为内容类型,请尝试添加

Your IIS is most likely not configured with SVG as a content type, try adding

<staticContent>
    <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>

在您的 web.config 的 范围内.

inside the <system.webServer> scope of your web.config.

这当然只有在您的应用程序是提供 svg 的应用程序时才有效.如果 svg 不包含在您的应用程序中,而是包含在 Web 服务器的单独目录中,您需要将相同的映射添加到您的 Web 服务器,而不是在mime-types"选项卡内.

This will of course only work if your application is the one serving up the svg. If the svg is not contained inside your application but in a separate directory of the web server, you'll need to add the same mapping to your web server instead inside the "mime-types" tab.

这篇关于svg 不适用于本地主机上的 IIS 网络服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆