Razor and HTML Helpers

前端 未结 4 1124
隐瞒了意图╮
隐瞒了意图╮ 2020-12-29 12:33

I\'m trying to port the old HTML.Image helper, that I\'m sure everyone has used at one point or another, and I\'m having issues. The following compiles fine:



        
4条回答
  •  悲哀的现实
    2020-12-29 13:31

    The Razor view engine will automatically HTML-escape strings rendered by @-blocks.
    To render actual HTML, you need to write an IHtmlString implementation in the @-block.

    Change your method to return HtmlString instead of string.

提交回复
热议问题