asp.net-mvc-3 - MVC3 C# 潜在危险的请求错误

标签 asp.net-mvc-3 html-encode

我有一个 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/

相关文章:

asp.net-mvc-3 - 使用 Massive ORM 填充下拉列表?

c# - 自定义 DataAnnotation 属性

asp.net-mvc - 如何使用 Error.cshtml View 中的过滤器放入 ViewBag 的数据?

javascript - 在数据存储中存储 HTML 并在 XSL 转换期间进行解码

php - 无法使用 str_replace 删除特殊字符

asp.net-mvc - MVC 3 Razor View 中的级联下拉菜单

sql - 使用 linq mvc 的 CTE 递归查询

asp.net - 如何对 URL 中的加号 (+) 进行编码

javascript - HTML 编码对 URL 无法正常工作

c# - 将 & 转换为 & 等