0

Am I doing something wrong here?

I have a text area on a view and am posting back the html contents. In VS 2008 and MVC 1.0 the following code successfully prevents input validation:

[HttpPost]
[ValidateInput(false)]
public ActionResult Index(int? id)
{
    return View();
}

If I execute this code in VS 2010 / MVC 2.0 I always get this error:

A potentially dangerous Request.Form value was detected from the client (body="
").

Any ideas?

Dustin Laine
  • 36,999
  • 10
  • 84
  • 123
Ben Foster
  • 33,525
  • 36
  • 167
  • 284

1 Answers1

0

Maybe this will help: Request Validation - ASP.NET MVC 2

Try adding this to your page directive:

ValidateRequest="false"
Community
  • 1
  • 1
Dustin Laine
  • 36,999
  • 10
  • 84
  • 123
  • The attribute works if you are targeting .net 4, but I am targeting 3.5 so am unable to add this attribute to web.config. – Ben Foster Mar 18 '10 at 23:23
  • unfortunately this does not work still. Perhaps it just the combination of targeting asp.net 3.5 with mvc 2.0? – Ben Foster Mar 20 '10 at 09:30