"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.

Written by Jonathan "JD" Danylko • Last Updated: • MVC •

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.

Did you like this content? Show your support by buying me a coffee.

Buy me a coffee  Buy me a coffee
Picture of Jonathan "JD" Danylko

Jonathan Danylko is a web architect and entrepreneur who's been programming for over 25 years. He's developed websites for small, medium, and Fortune 500 companies since 1996.

He currently works at Insight Enterprises as an Principal Software Engineer Architect.

When asked what he likes to do in his spare time, he replies, "I like to write and I like to code. I also like to write about code."

comments powered by Disqus