我有一个 MVC3 C#。网络应用程序。我们的属性之一使用 RTF 控件作为 TextBoxFor 控件:
@Html.TextAreaFor(model => model.SowDescription,
(object)new
{
rows = 7,
cols = 65,
@class = "celltext2 save-alert attachmentEditor",
disabled = "disabled"
}
attachmentEditor 类使用 CkEditor。因此,控件中嵌入了粗体、斜体等 html 标签。用户将一些数据粘贴到此 TextArea 中,我们收到此错误:
A potentially dangerous Request.Form value was detected from the client (SowDescription="<br /> <br /> <u><..."). ********
我们在其他情况下使用 HttpUtility.HtmlDecode,但在 Html.TextAreFor() 帮助程序中使用它时,我们会收到此错误:
Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.
我们有什么想法可以使用 Html.TextAreaFor() 帮助器进行编码/解码吗?
最佳答案
尝试使用 [AllowHtml]
属性装饰 SowDescription
View 模型属性。
关于asp.net-mvc-3 - MVC3 C# 潜在危险的请求错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14489853/