Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

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()

ExceptionCondition
InvalidOperationException

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.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0
Show:
© 2015 Microsoft