read the full download code: http://www.cckan.net/forum.php?mod=viewthread&tid=74
In the client's style box, enter "< any character > such as <user>" and so on when the error occurs
Sequential security attempts, such as Cross-site scripting attacks. 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: A potentially dangerous request.form value was detected from the client (txtname= "<fd>").
This is not set <pages validaterequest = "true" > This property this is the default, when we change to false this error will not appear, but we can not just change, so although not wrong, But have you ever thought that the program is not safe?
The right thing to do is to add the Page_Error () function on your current page to capture exceptions that occur during all page processing without processing. Then give the user a legitimate error message. If the current page does not have Page_Error (), the exception will be sent to Global.asax's Application_Error (), where you can write a generic exception-handling function. This default error page is displayed if two places do not have a write exception handler function.
protected void Page_Error (object sender, EventArgs e)
{
Exception ex = Server.GetLastError ();
If (ex is httprequestvalidationexception)
{
Response.Write ("Please do not enter such a character, hehe");
Server.ClearError (); If not ClearError () This anomaly will continue to be transmitted to Application_Error ().
}
}
This is a very important security feature provided by ASP.net. Because many programmers have no concept of security, even do not know the existence of XSS attack, know the initiative to protect less. Asp. NET to do the default security on this point. This allows programmers who are not very knowledgeable about security to write websites that have a certain amount of security protection.
But when I google search httprequestvalidationexception or "A potentially dangerous Request.Form value is detected from th E-Client ", it is surprising to find that most people give the solution is in the ASP.net page description by setting Validaterequest=false To disable this feature, and not to care about whether the programmer's website really does not need this feature. That's what I call a scared, scary-looking. Security awareness should always be in every programmer's heart, no matter how much you know about the concept of security, an active awareness in the brain, your site will be much safer.
Why do a lot of programmers want to ban validaterequest? Part of it is really the need for users to enter characters such as "<>". There's no need to say that. Another part of it is not that users are allowed to enter characters that are prone to XSS, but rather hate the way the error is generated, After all, a large paragraph of English plus a asp.net typical abnormal error message, it appears that the site error, rather than the user entered the illegal characters, but they do not know how to not let it error, their own to deal with the error.
For those of you who wish to handle this error message well without using the default ASP.net exception error message, you should not disable Validaterequest=false.
Example http://www.cckan.net/forum.php?mod=viewthread&tid=73