gpt4 book ai didi

asp.net-mvc - Kendo.editor 不解码 Html

转载 作者:行者123 更新时间:2023-12-04 12:51:08 24 4
gpt4 key购买 nike

我使用 Kendo.EditorFor 作为文本框,但在 View 中。它向我显示来自编辑器的 htmls 标签
这是我的 Controller :

public ActionResult Create(OpininonModel opininonmodel)
{
var addOpinion =
new OpininonModel
{
Title=opininonmodel.Title,
Content=Server.HtmlDecode(opininonmodel.Content),
Id=opininonmodel.Id,
IdUser=user,
};
db.Opinions.Add(addOpinion);
db.SaveChanges();
return RedirectToAction("Index");
}

我看到 <strong>123123</strong>在我看来。我应该 HtmlDecode别的地方还是?

我在我的 View 中试过这个:
@(Html.Kendo().EditorFor(model => model.Content).Encode(false))

但这给了我错误:
A potentially dangerous Request.Form value was detected from the client

最佳答案

如果您使用 html 帮助程序,您可以在从 View 中接收到值到 Controller 后对其进行解码。

它来自他们的文档:这是 link

在服务器上处理编辑器值

编辑器值将作为字符串发布并映射到具有小部件名称的变量。请注意,默认情况下发布的值是 HTML 编码的,以规避 ASP.NET 请求验证。为了解码该值,请使用 HttpUtility.HtmlDecode 方法。

[HttpPost]
public ActionResult Save(string editor)
{
string value = HttpUtility.HtmlDecode(editor);

return View();
}

我想这就是你要找的

关于asp.net-mvc - Kendo.editor 不解码 Html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15507407/

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