Hala Aly
Hala Aly

Reputation: 141

mvc3 field contains html text with validation

I have text field that may contain html text (like

<b>Dickens</b>

) in razor view, I display this field with

@Html.TextAreaFor(m => m.CurrentAuthor.AboutAuthorE)

when click in any submit buttons, mvc3 throw exception

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

how can I solve this error?

Upvotes: 0

Views: 832

Answers (1)

NinjaNye
NinjaNye

Reputation: 7126

If you need to store basic formatting consider bbcode

www.bbcode.org

A good editor is Markdown http://en.wikipedia.org/wiki/Markdown

If you do require more than the basic formatting that something like Markdown can give you consider adding the AllowHtml attribute to your model

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

for details see A potentially dangerous Request.Form value was detected from the client

Upvotes: 3

Related Questions