Server Error in 'ASP.Net'
Application.
A
potentially dangerous Request.Form value was detected from the client (TextBox1"=Hi").
Description:
Request Validation has
detected a potentially dangerous client input value, and processing of the
request has been aborted. This value may indicate an attempt to compromise the
security of your application, such as a cross-site scripting attack. You can
disable request validation by setting validateRequest=false in the Page
directive or in the configuration section. However, it is strongly recommended
that your application explicitly check all inputs in this case.
Exception Details: System.Web.HttpRequestValidationException: A
potentially dangerous Request.Form value was detected from the client
(TextBox1="Hi").
ASP.Net
By default validates all input controls for potentially unsafe contents that
can lead to Cross Site Scripting and SQL Injections. Thus it disallows such
content by throwing the above Exception. By default it is recommended to allow
this check to happen on each postback.
Solution
On many
occasions you need to submit HTML Content to your page through Rich TextBoxes
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"
CodeFile="TestWebPage.aspx.cs"
ValidateRequest="false" Inherits="TestWebPage" %>
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 " />