Page.ViewStateEncryptionMode Property

Definition

Gets or sets the encryption mode of the view state.

C#
[System.ComponentModel.Browsable(false)]
public System.Web.UI.ViewStateEncryptionMode ViewStateEncryptionMode { get; set; }

Property Value

One of the ViewStateEncryptionMode values. The default value is Auto.

Attributes

Exceptions

The value set is not a member of the ViewStateEncryptionMode enumeration.

The ViewStateEncryptionMode property can be set only in or before the page PreRender phase in the page life cycle.

Remarks

The ViewStateEncryptionMode property cannot be set in code. It can only be set in the @ Page directive or in the < element of the configuration file. Values set in the @ Page directive override any values set in the configuration file.

The syntax for setting this property in the @ Page directive is as follows:

C#
<%@ Page Language="C#" ViewStateEncryptionMode="Always" %>  

The syntax for setting this property in the configuration file is as follows:

C#
<system.web>  
  <pages viewStateEncryptionMode="Always" />  
</system.web>  

Custom control developers may wish to check the value of this property in code before saving potentially sensitive data to view state in their control.

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also