Displaying HTML String from Model in MVC Razor View

前端 未结 4 436
星月不相逢
星月不相逢 2021-01-12 01:43

I have a Model filed that returns an HTML string with line break BR tag, but How do I display that HTML on the browser ? The problem ins instead putting the line break, the

4条回答
  •  再見小時候
    2021-01-12 02:18

    Try this :

    @(new HtmlString(stringWithMarkup))
    

    and you can create a HTML helper too!:

    @helper RawText(string s) {
        @(new HtmlString(s))
    }
    

提交回复
热议问题