【问题标题】:mvc3 field contains html text with validationmvc3 字段包含带有验证的 html 文本
【发布时间】:2012-01-12 07:46:27
【问题描述】:

我有可能包含 html 文本的文本字段(如

<b>Dickens</b>

) 在剃刀视图中, 我用

显示这个字段
@Html.TextAreaFor(m => m.CurrentAuthor.AboutAuthorE)

当点击任何提交按钮时,mvc3 抛出异常

A potentially dangerous Request.Form value was detected from the client (CurrentAuthor.AboutAuthorE="<div align=justify><...").

我该如何解决这个错误?

【问题讨论】:

标签: html asp.net-mvc-3 razor


【解决方案1】:

如果您需要存储基本格式,请考虑 bbcode

www.bbcode.org

一个好的编辑器是 Markdown http://en.wikipedia.org/wiki/Markdown

如果您需要的不仅仅是 Markdown 之类的基本格式,可以考虑将 AllowHtml 属性添加到您的模型中

[AllowHtml] 
public string AboutAuthorE { get; set; }

详情见A potentially dangerous Request.Form value was detected from the client

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多