Rất có thể là, nếu một người nào đó đi vào, họ đang không tốt. Vì vậy, đồng hồ cho các lỗ hổng phổ biến nhất và cản trở họ. Hãy thử vào trong một hộp văn bản và trình trang. Bạn nhìn thấy một thông báo lỗi tương tự như yêu cầu có khả năng nguy hiểm. | Chapter 19 Validation in Depth 319 tries to protect you The team at Microsoft knows that hackers often enter malicious JavaScript in text boxes. Chances are if someone enters SCRIPT they re up to no good. Therefore ASPNET watches for the most common vulnerabilities and thwarts them. Try entering SCRIPT in a text box and then submitting the page. You see an error message similar to A potentially dangerous Request. Form value was detected from the client. If the default protection is seriously hampering your application switch it off. In the @Page directive you need to insert this property value pair ValidateRequest false Of course you want to validate the text box input very carefully after removing a built-in defense. See the Defanging Markup for Safety section later in this chapter for an easy way to handle HTML. Checking and Comparing Values The CompareValidator control offers three validators in one compare values in two controls compare a value in a control against a constant value and test whether a user has entered a valid data type. The available operators are Equal NotEqual GreaterThan Greater ThanEqual LessThan LessThanEqual and DataTypeCheck. The operator names are self-explanatory. For example GreaterThanEqual validates when the input value is greater than or equal to a second control s value or a constant value . Comparing values in two controls The CompareValidator can determine whether the value in one text box is greater than the value in a second text box. Follow these steps to display an error message if the validation test fails 1. Add two TextBox controls to a Web form. 2. Add a Button control to the page. 3. From the Validation category of the Toolbox add a CompareValidator to the page. 4. In the CompareValidator control s Properties window set the following proper ties and corresponding values 320 Part IV Tracking Users Controlling Access and Implementing Security Property Value ControlToCompare TextBox2 or .