MVC3 C#有潜在危险的请求错误 [英] MVC3 C# Potentially dangerous request error
问题描述
我有一个MVC3 C#。 Web应用程序。我们的一个属性使用一个RTF控制我们的TextBoxFor控制:
I have an MVC3 C#. Web App. One of our properties uses an RTF control for our TextBoxFor controls:
@Html.TextAreaFor(model => model.SowDescription,
(object)new
{
rows = 7,
cols = 65,
@class = "celltext2 save-alert attachmentEditor",
disabled = "disabled"
}
在attachmentEditor类使用CKEDITOR。因此,有嵌入在粗体,斜体等控制html标签的用户粘贴一些数据此TextArea,我们收到此错误:
THe attachmentEditor class uses CkEditor. So there are html tags embedded in the control for Bold, Italics, etc. A user pasted some data into this TextArea and we received this error:
A potentially dangerous Request.Form value was detected from the client (SowDescription="<br /> <br /> <u><..."). ********
我们使用HttpUtility.HtmlDe code在其他情况下,但使用它在Html.TextAreFor()帮助我们得到这个错误:
We use HttpUtility.HtmlDecode in other cases, but the using it in the Html.TextAreFor() helper we get this error:
Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.
任何想法如何,我们可以连接code /德code中的使用Html.TextAreaFor()帮助?
Any ideas how we can Encode/Decode the using the Html.TextAreaFor() helper?
推荐答案
尝试装饰 SowDescription
视图模型与属性 [AllowHtml]
属性。
Try decorating the SowDescription
viewmodel property with the [AllowHtml]
attribute.
这篇关于MVC3 C#有潜在危险的请求错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!