Solution to potentially dangerous Request.Form value was detected from the client.

Here we will see how to solve the error for potentially dangerous Request.Form value was detected from the client. Basic reason for the occurrence of this error is because asp.net prevents any attempt to compromise the security of application by script injection like cross site scripting etc.

This error occurs when end user enters any scripting / html tag<> in the inputbox. You can disable request validation by setting validateRequest=false in the page directive or in the configuration section but it is strongly recommended that your application explicitly check all inputs in this case.

To resolve this issue we can do following things.

1. Set validateRequest property to false in page directive.

<%@ Page validateRequest="false" %>

2. Set validateRequest property to false in the <pages /> section under <system.web>
section of web.config file if you want to turn off request validation globally(Entire Application).

<configuration>
   <system.web>
      <pages validateRequest="false" />
   </system.web>
</configuration>

3. For .NET 4 or higher we need to add requestValidationMode=”2.0″ to the httpRuntime configuration section of the web.config file

<httpRuntime requestValidationMode="2.0"/>

Asp.net validates all input controls for potentially unsafe contents that can lead to cross site scripting and Sql injections and so if you disable the request validation then you should check the input for any cross-site scripting (XSS) attacks.

Advertisements

Check Un-check All CheckBox Inside A Repeater

Here we will see how to check uncheck all items in repeater using jQuery. Here we have an additional checkbox (Select All) which will be used to check all the checkboxes that are present in the repeater control.

The code is as follows: Continue reading Check Un-check All CheckBox Inside A Repeater

Display Line Break In Javascript Alert Message Box.

Here we will see how to add a new line break (<br/>) to javaScript alert message box.

To implement this functionality you have to use new line character (\r\n).

Code is as follows: Continue reading Display Line Break In Javascript Alert Message Box.