"Potentially dangerous Request.Form value detected from client" error in asp.net

Source: Internet
Author: User

When submitting the form, ASP.net prompts: "From the client (...) A potentially dangerous request.form value was detected in the. The request validation feature in ASP.net provides a level of protection against XSS attacks, and ASP.net request validation is initiated by default. This gives a solution for each version of. Net.

asp.net 2.0 usual workaround

Scenario One:

Add the Page item in the. aspx file validaterequest= "false" as follows:

<%@ page Val Idaterequest= "false" language= "C #" autoeventwireup= "true" codefile= "Test2.aspx.cs" inherits= "test2"%>

Scenario Two:

Modify the web.config profile

<system.web>
<pages validaterequest= "false" >
</pages>
</system.web>

Summary: validaterequest This sentence we know is off verification, that is, submit with tag, such as <strong> bold </strong> Such values, asp.net does not complain. The use of scenario one is recommended here, as the scheme one modifies the Test.aspx page, and if you use scenario two, the entire solution becomes validaterequest= "false".

asp.net 4.0 solutions

4.0 and 2.0 are the same, but note that starting with the. NET Framework 4.0, ASP.net begins to force the detection of request parameter security, and we can modify the web.co Nfig to restore the 2.0 version of the model. The

methods are as follows:

modifying web.config, adding Requestvalidationmode= "2.0" property value

< System.web>
<pages validaterequest= "false" ></PAGES>
</SYSTEM.WEB>

4.0 more than a requestvalidationmode, what does that mean? The

Requestvalidationmode has two values:

• 2.0 enable request verification only for Web pages. Whether it is enabled or closed depends on the validaterequest.

• 4.0 default values. Any HTTP request will enable request verification, which means not just a Web page, but also cookies. The force is enabled at this time, regardless of the validaterequest value.

Because requestvalidationmode= "4.0" is mandatory, we will find that validaterequest is not turned off for request validation in. NET Framework 4.0, and the Requestva Lidationmode is set to 2.0.

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.