【发布时间】:2014-01-24 17:48:36
【问题描述】:
我有一些 HTML 存储在数据库中,看起来完全像这样:
<strong><a href="http://www.google.com" target="_blank">Maintenance scheduled </a></strong>tomorrow
我想将其输出到正确格式化为 HTML 的 Razor 视图。我不想看到< 和>,我只想要HTML。
您可以从这个 sn-p 中看到我尝试了几种不同的方法:
div id="maintenanceMessage">
@*@HttpUtility.HtmlDecode(sysSettings.MaintenanceMessage)*@
@*@HttpUtility.HtmlDecode((new HtmlString(sysSettings.MaintenanceMessage)).ToString())*@
@Html.Raw(sysSettings.MaintenanceMessage)
</div>
但在任何情况下,它都会一直显示为文本:
<strong><a href="http://www.google.com" target="_blank">Maintenance scheduled </a></strong>tomorrow
而不是格式化的 HTML。 我不确定我做错了什么?
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-4 c#-4.0 razor