Tuesday 9 August 2016

A potentially dangerous Request.form value was detected from the client in asp.net with c#

Exception : A potentially dangerous Request.form value was detected  from the client in asp.net with c#

Image

Solution :

On many time you need to submit HTML Content to your page through  TextAreas or Rich Text Editors. In that case you can avoid this exception by setting the ValidateRequest tag in the @Page Directive to false.

<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest = "false"

This will disable the validation of requests for the page you have set the ValidateRequest flag to false. If you want to disable this check throughout your Web Application you’ll need to set it  false in your web.config <system.web> section
<pages validateRequest ="false" />

For .Net 4.0 or higher frameworks you will need to also add the following line in the <system.web> section to make the above work.
<httpRuntime requestValidationMode = "2.0" />

No comments:

Post a Comment