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

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

July 27th, 2009 • MVC •
0 (0 votes)

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.

Was this informative? Share it!

Looking to become a better developer?

Sign up to receive ReSharper Design Pattern Smart Templates, ASP.NET MVC Guidelines Checklist, and Newsletter Updates!

Picture of Jonathan Danylko

Jonathan Danylko is a freelance web architect and avid programmer who has been programming for over 20 years. He has developed various systems in numerous industries including e-commerce, biotechnology, real estate, health, insurance, and utility companies.

When asked what he likes to do in his spare time, he replies, "Programming."

comments powered by Disqus