RequestValidator::IsValidRequestString Method
Validates a string that contains HTTP request data.
Assembly: System.Web (in System.Web.dll)
protected public: virtual bool IsValidRequestString( HttpContext^ context, String^ value, RequestValidationSource requestValidationSource, String^ collectionKey, [OutAttribute] int% validationFailureIndex )
Parameters
- context
- Type: System.Web::HttpContext
The context of the current request.
- value
- Type: System::String
The HTTP request data to validate.
- requestValidationSource
- Type: System.Web.Util::RequestValidationSource
An enumeration that represents the source of request data that is being validated. The following are possible values for the enumeration:
QueryString
Form
Cookies
Files
RawUrl
Path
PathInfo
Headers
- collectionKey
- Type: System::String
The key in the request collection of the item to validate. This parameter is optional. This parameter is used if the data to validate is obtained from a collection. If the data to validate is not from a collection, collectionKey can be nullptr.
- validationFailureIndex
- Type: System::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.
You implement this method to perform custom validation of request data. The base behavior of the IsValidRequestString(HttpContext, String, RequestValidationSource, String, Int32%) method is like the behavior that ASP.NET implements internally to check for dangerous strings in cross-site scripting validation. For more information, see How To: Prevent Cross-Site Scripting in ASP.NET.
If custom validation logic detects an error, this method should return false and provide a value in validationFailureIndex to indicate the starting point of the text that caused the error. The value in validationFailureIndex must be 0 or a positive integer.
The logic in a request validation check proceeds as follows:
The HttpRequest class performs a null-character removal check on the incoming data.
The HttpRequest class calls either the IsValidRequestString method (the default implementation of the base method) or calls a derived version of the method.
If IsValidRequestString method returns false to indicate a validation failure, ASP.NET constructs an error string (if necessary) and throws an HttpRequestValidationException exception.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.