asp.net detection of potentially dangerous request.form value errors from the client _ practical Tips

Source: Internet
Author: User
Tags html tags
From client (ftbcontent= "<p><a href=" http://l ...) A potentially dangerous request.form value was detected in the.

Note: The request validation process detects a potentially dangerous client input value and the processing of the request has been aborted. This value may indicate an attempt to compromise the security of an application, such as a cross-site scripting attack. You can disable request validation by setting Validaterequest=false in the Page directive or configuration section. However, in this case, it is strongly recommended that the application explicitly check all input.

Exception Details: System.Web.HttpRequestValidationException: From Client (ftbcontent= "<p><a href= http://l ...") Potentially dangerous Request.Form value detected in
The above is the system error information. The reason is that, in ASP.net 1.1, when the ValidateRequest property on the @Page instruction is opened, it checks to make sure that the user does not send potentially dangerous HTML tags in the query string, Cookie, or form field. If this condition is detected, an exception is thrown and the request is aborted. This property is open by default, and you can be protected without doing anything. If you want to allow HTML markup to pass, you must actively disable this property.
Solution:
Method one, modifying. aspx files
In the. aspx file, add validaterequest= "false" in the form:
<%@ Page validaterequest= "false" language= "C #" codebehind= "WriteNews.aspx.cs" autoeventwireup= "false" inherits= " News.writenews "%>
Method Two, configure Web.config file
<?xml version= "1.0" encoding= "Utf-8"?>
<configuration>
<system.web>
<!--writenews.aspx You must add the statement when you use the content edit box, you cannot request a value
-->
<pages validaterequest= "false"/>
</system.web>
</configuration>
Recommended method of use one.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.