Asp.net detects potentially dangerous request. Form values from the client

Source: Internet
Author: User
When an HTML Tag value is entered in the textbox of the Asp.net page and the page commits an action,. vs automatically checks this unsafe error.
For example: Potentially dangerous request. Form values are detected from the client (ctl00 $ maincontentplaceholder $ txtowner = "<D> ")
There are two solutions:
1. capture this error and send a friendly message
// When the user inputs an insecure HTML Tag, for example, <TD>, the system automatically reports a security error. This method is to capture this error!
Protected void page_error (Object sender, eventargs E)
{
Exception EX = server. getlasterror ();
If (httpcontext. Current. server. getlasterror () is httprequestvalidationexception)
{
Httpcontext. Current. response. Write ("an insecure HTML Tag exists in the volume. Please refer to the valid string! <A href = \ "javascript: history. Back (0); \"> return </a> ");
Httpcontext. Current. server. clearerror ();
}
}
2. disable this function.
Add validaterequest = "false" to the page on the front-end page"
<% @ Page Language = "C #" autoeventwireup = "true" codefile = "bp_modelspec_copy.aspx.cs" inherits = "productspec_bp_modelspec_copy" validaterequest = "false" %>

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.