Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It is the <a href="http://msdn.microsoft.com/en-us/library/system.web.httprequest.params.aspx" rel="nofollow"><code>HttpRequest.Params</code></a> getter that is throwing this exception. This getter basically builds and returns a key/value pair collection which is the aggregation of the QueryString, Form, Cookies and ServerVariables collections in that order. Now what is important is that when you use this getter it will always perform request validation and this no matter whether you used the <code>[AllowHtml]</code> attribute on some model property or if you decorated the controller action with the <code>[ValidateInput(false)]</code> attribute and disabled all input validation.</p> <p>So this is not really a bug in the <code>AllowHtml</code> attribute. It is how the <code>Params</code> property is designed.</p> <p>As @Adam mentioned in his answer you should avoid accessing request values manually. You should use value providers which take into account things such as disabled request validation for some fields.</p> <p>So simply add another property to your view model:</p> <pre><code>public class ArticleModel: BaseModel { [StringLength(8000, ErrorMessage = "Long description must be in 8000 characters or less")] [AllowHtml] public string LongDescription { get; set; } public string Button { get; set; } } </code></pre> <p>and then in your controller action:</p> <pre><code>[HttpPost] public ActionResult AddEdit(ArticleModel model) { string buttonName = model.Button; if (buttonName == "Cancel") { return RedirectToAction("Index"); } // something failed if (!ModelState.IsValid) { } // Update the articles } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload