ViewStateEncryptionMode Property
Collapse the table of content
Expand the table of content

Page.ViewStateEncryptionMode Property


Gets or sets the encryption mode of the view state.

Namespace:   System.Web.UI
Assembly:  System.Web (in System.Web.dll)

public ViewStateEncryptionMode ViewStateEncryptionMode { get; set; }

Property Value

Type: System.Web.UI.ViewStateEncryptionMode

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

Exception Condition

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


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

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

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

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

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

  <pages viewStateEncryptionMode="Always" />

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.

.NET Framework
Available since 2.0
Return to top
© 2015 Microsoft