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.