Embedding SVG in ASP.net page

前端 未结 3 1805
太阳男子
太阳男子 2021-02-15 21:51

I would like to embed svg directly into my ASP.net-MVC view so that the output looks something like this:


    
         ... &         


        
相关标签:
3条回答
  • 2021-02-15 22:32

    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.

    Your partial would then look like

    @Html.Partial("~/Views/pathtosvg/svg.cshtml")

    0 讨论(0)
  • 2021-02-15 22:37

    Can you use just file include same as php file?

    Example:

    <!--#include file="image.svg"-->
    

    This syntax should work similar to php include, but for asp.net

    0 讨论(0)
  • 2021-02-15 22:57

    Renaming SVG files and using Html.Partial should do the trick, but I didn't like to be renaming files in order to achieve it. So, this way, you can keep your files as they are.

    @Html.Raw(File.ReadAllText(Server.MapPath("~/image.svg")))
    
    0 讨论(0)
提交回复
热议问题