April 1, 2013

Avoid Potential Dangerous Request Error Message

You will get this error message from server when server see HTML mark up in HTML fields. To avoid error message of "Potential Dangerous Request", you need to do following precautions.

1.  Add ValidateRequest & EnableEventValidation attribute as "false" in @Page tag as:


<%@ Page Title="Untitle Page" Language="C#" MasterPageFile="~/Master.Master" 
    AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="_Default" 
    EnableEventValidation="false" ValidateRequest="false" %>


2. If still receive an error, then add requestValidationMode attribute in httpRuntime configuration section in web.config file as:


<httpRuntime requestValidationMode="2.0"/>

3.   But If there is no httpRuntime section in web.config file then add ValidateRequest attribute in web.config file within <system.web> tag as:


<pages validateRequest="false" />

If you have any issue remaining then let me know. Stay tune.

No comments:

Post a Comment