我正在从文本文件中读取博客文章的内容,它是 html 格式,我想在页面上将它们显示为呈现的 html,但它并没有发生,它的所有显示都是带有 html 标签等的简单文本。我已经尝试了三种可能的方法来使其工作,但所有方法都显示未呈现的 html:
<section id="content">
@Server.HtmlDecode(content[2])
@content[2]
@MvcHtmlString.Create(content[2])
@Html.Raw(content[2])
</section>
content[2] 包含 html 文本:
"<p itemprop=\"articleBody\" style=\"font-size:1.5em;line-height:1.467em;font-family:georgia, 'times new roman', times, serif;text-align:left;\">The movie, which tells the story of the way the small-market Oakland Athletics used outside-the-box statistical analysis to compete successfully against talent-rich competition, resonated with Snedeker, who is not the longest, straightest or most accurate hitter in golf.</p>
显示为:
<p itemprop="articleBody" style="font-size:1.5em;line-height:1.467em;font-family:georgia, 'times new roman', times, serif;text-align:left;">The movie, which tells the story of the way the small-market Oakland Athletics used outside-the-box statistical analysis to compete successfully against talent-rich competition, resonated with Snedeker, who is not the longest, straightest or most accurate hitter in golf.</p>
如果问题是因为保存的内容实际上并没有从<
&打开右括号,>
而是它们有它们的 ascii 代码,请展示我如何阻止它发生,因为它只是一个带有文本区域的简单表单,我在其中输入此内容(使用Kendo UI
Editor
)并且在我在控制器中收到此消息后发布后,它具有 ascii 代码而不是实际字符。