"A potentially dangerous Request.Form value was detected from the client" fix for ASP.NET MVC

July 27th, 2009

Here is a gotcha that I found while I had my "WebForms" hat on.

I've been working on a project and got the dreaded error:

"A potentially dangerous Request.Form value was detected from the client"

Well, after trying the "<@page validateRequest="false"...>", I realized that didn't work. So I started looking through the code and found the attribute:

[ValidateRequest(false)]

You need to attach the ValidateRequest(false) attribute to the method that is receiving the post.

Problem solved.

NOTE: However, make sure you are catching any type of malicious injections that could occur.