Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
593 views
in Technique[技术] by (71.8m points)

asp.net - svg is not working on IIS webserver on localhost

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.

What is the problem?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...