PagesSection.ValidateRequest 属性

定义

获取或设置一个值,该值确定 ASP.NET 是否针对危险值检查来自浏览器的输入。Gets or sets a value that determines whether ASP.NET examines input from the browser for dangerous values. 有关详细信息,请参阅脚本侵入概述For more information, see Script Exploits Overview.

public:
 property bool ValidateRequest { bool get(); void set(bool value); };
[System.Configuration.ConfigurationProperty("validateRequest", DefaultValue=Mono.Cecil.CustomAttributeArgument)]
public bool ValidateRequest { get; set; }
member this.ValidateRequest : bool with get, set
Public Property ValidateRequest As Boolean

属性值

Boolean

如果 ASP.NET 针对危险值检查来自浏览器的输入,则为 true;否则为 falsetrue if ASP.NET examines input from the browser for dangerous values; otherwise, false. 默认值是 trueThe default value is true.

属性

示例

下面的代码示例说明如何使用 ValidateRequest 属性。The following code example shows how to use the ValidateRequest property.

// Get the current ValidateRequest property value.
Console.WriteLine(
    "Current ValidateRequest value: '{0}'",
    pagesSection.ValidateRequest);

// Set the ValidateRequest property to true.
pagesSection.ValidateRequest = true;
' Get the current ValidateRequest property value.
Console.WriteLine( _
    "Current ValidateRequest value: '{0}'", _
    pagesSection.ValidateRequest)

' Set the ValidateRequest property to true.
pagesSection.ValidateRequest = True

注解

请求验证的执行方式是将所有输入数据与潜在危险值的列表进行比较。Request validation is performed by comparing all input data to a list of potentially dangerous values. 如果出现匹配项,ASP.NET 将引发 HttpRequestValidationExceptionIf a match occurs, ASP.NET raises an HttpRequestValidationException.

适用于

另请参阅