RegisterRequiresViewStateEncryption Method
Collapse the table of content
Expand the table of content

Page.RegisterRequiresViewStateEncryption Method ()


Registers a control with the page as one requiring view-state encryption.

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

public void RegisterRequiresViewStateEncryption()

Exception Condition

The RegisterRequiresViewStateEncryption method must be called before or during the page PreRenderphase in the page life cycle.

If you are developing a custom control that deals with potentially sensitive information, call the RegisterRequiresViewStateEncryption method to register the control with the page and ensure view state for the control is encrypted.

The entire page state will be encrypted if the ViewStateEncryptionMode is set to Auto or Always.

The following code example demonstrates setting the view-state encryption mode for a Page object and requesting encryption of the view state through RegisterRequiresViewStateEncryption. In this example, view state will be encrypted when customer information is retrieved from a database.

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