Welcome to Vishwa's blog - Technology, Spirituality and More...

Error: A potentially dangerous Request.Form value

Just came across this error when I upgraded my Blog from .NET 3.5 to .NET 4.0  - A potentially dangerous Request.Form value was detected from the client .....

Ok, so first I thought may be I missed the Page directives. Checked that and it was there, played around with different settings and configurations, but nothing helped.

But finally the solution was revealed:) and it was very simple as you can see below. In .NET 4.0, Microsoft added another parameter “requestValidationMode” in httpruntime which will stop this error. So open your web.config and add following.


Code Snippet
  1. <system.web>
  3.      <httpRuntimerequestValidationMode="2.0"/>
  5. </system.web>



Remember if your website is still using .NET 2.0 and getting the same error, make sure that the page directive “ValidateRequest” is set to false.

Code Snippet
  1. <%@ Page Language="C#" MasterPageFile="masterPage.master" AutoEventWireup="true" CodeFile="TestPage.aspx.cs" Inherits="TestPage" ValidateRequest="False" %>

Comments (1) -

  • Ravindranath reddy

    8/10/2010 6:50:53 PM | Reply

    thank u..for sharing the information....saving the valuable time....very thankfull..