您可以使用正则表达式删除标签:
string plainText = Regex.Replace(MyVariable, "<.*?>", string.Empty);
在你的 file.cshtml 中你可以尝试使用 html.WriteRaw() 帮助器。
但在.net core中必须指定正确的mvn类命名空间。
我在 cstml 文件中编写了自己的辅助方法。我使用 WriteLiteral() 方法将所有标签(如 /֒ 或 /
)转换为纯文本。 Writelitaeral 将文本直接写入缓冲区,因此我的方法返回空字符串。
@functions {
public string RemoveFormat(string message)
{
WriteLiteral(message);
return "";
}
}
...
<p>
@RemoveFormat(@Model.data)
...