RequestValidator.InvokeIsValidRequestString(HttpContext, String, RequestValidationSource, String, Int32) 方法
定义
提供一种公共方法,其调用受保护的 IsValidRequestString(HttpContext, String, RequestValidationSource, String, Int32) 方法来验证 HTTP 请求数据。Provides a public method that calls the protected IsValidRequestString(HttpContext, String, RequestValidationSource, String, Int32) method in order to validate HTTP request data.
public:
bool InvokeIsValidRequestString(System::Web::HttpContext ^ context, System::String ^ value, System::Web::Util::RequestValidationSource requestValidationSource, System::String ^ collectionKey, [Runtime::InteropServices::Out] int % validationFailureIndex);
public bool InvokeIsValidRequestString (System.Web.HttpContext context, string value, System.Web.Util.RequestValidationSource requestValidationSource, string collectionKey, out int validationFailureIndex);
member this.InvokeIsValidRequestString : System.Web.HttpContext * string * System.Web.Util.RequestValidationSource * string * int -> bool
Public Function InvokeIsValidRequestString (context As HttpContext, value As String, requestValidationSource As RequestValidationSource, collectionKey As String, ByRef validationFailureIndex As Integer) As Boolean
参数
- context
- HttpContext
请求的 HTTP 上下文。The HTTP context of the request.
- value
- String
要验证的 HTTP 请求数据。The HTTP request data to validate.
- requestValidationSource
- RequestValidationSource
一个枚举,表示正在验证的请求数据的源。An enumeration that represents the source of request data that is being validated. 以下是枚举的可能值:The following are possible values for the enumeration:
QueryStringFormCookiesFilesPathPathInfoHeaders
- collectionKey
- String
(可选)验证项的请求集合中的键。(Optional) The key in the request collection of the item to validate. 如果从集合中获得要验证的数据,则使用此参数。This parameter is used if the data to validate is obtained from a collection. 如果要验证的数据不是集合中的数据,则此参数可以为 null。If the data to validate is not from a collection, this parameter can be null.
- validationFailureIndex
- Int32
此方法返回时,指示请求集合中有问题或无效文本的从零开始的起点。When this method returns, indicates the zero-based starting point of the problematic or invalid text in the request collection. 此参数未经初始化即被传递。This parameter is passed uninitialized.
返回
如果要验证的字符串不包含可用于恶意脚本攻击的未编码字符,则为 true;否则为 false。true if the string to validate does not contain unencoded characters that could be used in a malicious scripting attack; otherwise, false.
注解
InvokeIsValidRequestString方法提供对受保护方法的公共访问 IsValidRequestString 。The InvokeIsValidRequestString method provides public access to the protected IsValidRequestString method. 这使你可以为类创建自定义包装器类 RequestValidator 并调用 IsValidRequestString 方法,而不必从类继承 RequestValidator 。This lets you create a custom wrapper class for the RequestValidator class and call the IsValidRequestString method without having to inherit from the RequestValidator class.
有关请求验证的信息,请参阅 UnvalidatedRequestValues 。For information about request validation, see UnvalidatedRequestValues.