Muokkaa

Jaa


HttpRuntimeSection.RequestValidationMode Property

Definition

Gets or sets a version number that indicates which ASP.NET version-specific approach to validation will be used.

public:
 property Version ^ RequestValidationMode { Version ^ get(); void set(Version ^ value); };
[System.ComponentModel.TypeConverter(typeof(System.Web.Configuration.VersionConverter))]
[System.Configuration.ConfigurationProperty("requestValidationMode", DefaultValue="4.0")]
public Version RequestValidationMode { get; set; }
[<System.ComponentModel.TypeConverter(typeof(System.Web.Configuration.VersionConverter))>]
[<System.Configuration.ConfigurationProperty("requestValidationMode", DefaultValue="4.0")>]
member this.RequestValidationMode : Version with get, set
Public Property RequestValidationMode As Version

Property Value

A value that indicates which ASP.NET version-specific approach to validation will be used. The default is 4.5.

Attributes

Remarks

The RequestValidationMode property specifies which ASP.NET approach to validation will be used. This can be the algorithm that is used in versions of ASP.NET earlier than version 4, or the version that is used in .NET Framework 4. The property can be set to the following values:

  • 4.5 (the default). In this mode, values are lazily loaded, that is, they are not read until they are requested.

  • 4.0 The HttpRequest object internally sets a flag that indicates that request validation should be triggered whenever any HTTP request data is accessed. This guarantees that the request validation is triggered before data such as cookies and URLs are accessed during the request. The request validation settings of the <pages> element (if any) in the configuration file or of the @ Page directive in an individual page are ignored.

  • 2.0. Request validation is enabled only for pages, not for all HTTP requests. In addition, the request validation settings of the <pages> element (if any) in the configuration file or of the @ Page directive in an individual page are used to determine which page requests to validate.

  • 0.0. Request validation is disabled for the application. 0.0 is only recognized in ASP.NET 4.6 and later.

The value that you assign to this property is not validated to match a specific version of ASP.NET.

In ASP.NET 4.5, and earlier any numeric value less than 4.0 (for example, 3.7, 2.9, or 2.0) is interpreted as 2.0. Any number greater than 4.5 is interpreted as 4.5.

In ASP.NET 4.6, and later any numeric value greater than 0.0 and less than 4.0 (for example, 3.7, 2.9, or 1.0) is interpreted as 2.0. Any number greater than 4.5 is interpreted as 4.5

To set this value in a configuration file, you can assign a value to the requestValidationMode attribute of the httpRuntime element. For more information, see httpRuntime Element (ASP.NET Settings Schema).

Applies to