0

So MVC is throwing a dangerous request error when submitting a form value containing markup (e.g. <http://www.stuff.com>). Is it possible to have the form validation still work but return a Model state error instead of throwing a dangerous request exception?

Sinaesthetic
  • 11,426
  • 28
  • 107
  • 176

1 Answers1

1

there are a few options, you could use the attribute [AllowHtml] and then check for html server side, and then add model state errors and return, or you could also use a hidden field, and encode it so that the < becomes &lt; a few other options are listed here and here on the validation part.

I would suggest looking at HtmlEncode, as there may or may not be a legitimate case for someone to write < or > in a field.

Community
  • 1
  • 1
tophallen
  • 1,033
  • 7
  • 12