使用剃刀显示编码的 html [英] Display encoded html with razor
本文介绍了使用剃刀显示编码的 html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将编码的 HTML 存储在数据库中.
我能正确显示它的唯一方法是:
@MvcHtmlString.Create(HttpUtility.HtmlDecode(Model.Content));
太丑了.有没有更好的方法来做到这一点?
解决方案
试试这个:
@Html.Raw(HttpUtility.HtmlDecode(Model.Content))
I store encoded HTML in the database.
The only way i could display it correctly is :
<div class='content'>
@MvcHtmlString.Create(HttpUtility.HtmlDecode(Model.Content));
</div>
It's ugly. Is there any better way to do this?
解决方案
Try this:
<div class='content'>
@Html.Raw(HttpUtility.HtmlDecode(Model.Content))
</div>
这篇关于使用剃刀显示编码的 html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文