Search code examples
asp.net-mvc-2ckeditor

"A potentially dangerous Request.Form..." error in MVC 2.0


ValidateInputAttribute, ValidateInput, httpRuntime requestValidationMode="2.0" in web.config (system.web) all do not fix, also the "ValidateRequest="false"" in my view. I'm using MVC 2, Visual Studio 2010, .NET 4.0, and I'm still getting the following error:

A potentially dangerous Request.Form value was detected from the client (Body="<p>test</p>").

This is with CKEditor. I've already looked at MVC2 application with Ckeditor "potentially dangerous Request.Form, but that might be old.

Please help!! Thanks.

UPDATE:

Soooo.... turns out you have to tweak the root web.config, and NOT the web.config that's in your Views folder. sweet mercy. thanks everyone!


Solution

  • I have found that you need to go to the Action on the controller which is recieving the post data from the CKEditor enhanced form and on that action add the attribute like this:

    [ValidateInput(false)]
    public ActionResult UpdateText(string HtmlText)
    {
      Repository.Save(HtmlText);  
    
      ...
    
      return View();
    }