ASP. NET detects potentially dangerous data in requests because it may include HTML tags or scripts, asp.net requests

Source: Internet
Author: User

ASP. NET detects potentially dangerous data in requests because it may include HTML tags or scripts, asp.net requests

Solution:
Method 1. Modify the. aspx File
Add validateRequest = "false" to the. aspx file, for example:
<% @ Page validateRequest = "false" language = "c #" Codebehind = "WriteNews. aspx. cs" AutoEventWireup = "false"
Inherits = "News. WriteNews" %>
Method 2: configure the web. config file
<? Xml version = "1.0" encoding = "UTF-8"?>
<Configuration>
<System. web>
<! -- This statement must be added when WriteNews. aspx uses the content edit box. Otherwise, the Request value cannot be added.
-->
<Pages validateRequest = "false"/>
</System. web>
</Configuration>
Recommended method 1


However, the preceding settings are only valid for ASP. NET4.0 and later versions. In ASP. NET4.0, we need more configuration lines:

 

Set at the global level (in Web. config)
<Configuration>
<System. web>
<HttpRuntime requestValidationMode = "2.0">

 

This is explained on the page where an error occurs. In actual use, this is not only the case, but I also found that the requestValidationMode can be set to be smaller than 4.0, for example, 1.0, 2.0, 3.0, and 3.9, the error code 2.0 is specified in the error message to describe ASP. NET 2.0 by default.

 

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.