Fixing “A potentially dangerous Request.Form value” exception

I was merrily converting a site from .NET 2.0 to .NET 4.0 when…

Yes, I did say I was upgrading from 2.0 to 4.0.

Anyways, when I did this and used a page that allowed HTML elements to be entered in a TextBox, I got the oh-so helpful error “A potentially dangerous Request.Form value was detected…”

No problem, I would just add the ‘ValidateRequest=”false” ‘ tag at the top of the page and get back to business. But business was not happening, because I added the tag, and nothing happened. Luckily, a little browsing found the solution, which was editing the web.config file and adding the requestValidationMode:

    <httpRuntime requestValidationMode="2.0"/>

That did the trick.

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: