将SVG嵌入ASP.net页面 [英] Embedding SVG in ASP.net page
本文介绍了将SVG嵌入ASP.net页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想直接将svg嵌入我的ASP.net-MVC视图中,以便输出看起来像这样:
I would like to embed svg directly into my ASP.net-MVC view so that the output looks something like this:
<html>
<body>
<svg> ... </svg>
</body>
</html>
使用PHP时,我会这样做:
With PHP I would do this like so:
<? include('image.svg'); ?>
我尝试了@Html.Partial('image.svg')
,但出现了错误.有没有办法解决这个问题或我可以尝试的另一种方法?
I tried @Html.Partial('image.svg')
but got an error. Is there a way to fix this or another method I can try?
推荐答案
将SVG嵌入到cshtml视图文件而不是.svg文件中,那么您应该可以使用@ Html.Partial呈现它.
Embed your SVG into a cshtml view file instead of a .svg file, then you should be able to use @Html.Partial to render it.
您的局部显示如下
@Html.Partial("~/Views/pathtosvg/svg.cshtml")
这篇关于将SVG嵌入ASP.net页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文