gpt4 book ai didi

c# - Html.Raw 将 HTML 输出为文本

转载 作者:太空宇宙 更新时间:2023-11-03 20:12:03 26 4
gpt4 key购买 nike

我的模型中有一个属性 string内容类似于:

<p>Hello</p>`

使用 @Html.Raw(myProperty)输出到浏览器

<p>Hello</p>

当我期待

Hello

我试过做 @Html.Raw(Html.Raw(myProperty))但这将它恢复为原始字符串。

有没有什么方法可以在不使用 .Replace("&lt;", "<") 的情况下按预期呈现此文本?等等?

最佳答案

尝试以下操作:

@Html.Raw(HttpUtility.HtmlDecode(myProperty))

关于c# - Html.Raw 将 HTML 输出为文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19400304/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com