This documentation is archived and is not being maintained.

Page.ViewStateUserKey Property

Assigns an identifier to an individual user in the view-state variable associated with the current page.

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

Public Property ViewStateUserKey As String
Dim instance As Page
Dim value As String

value = instance.ViewStateUserKey

instance.ViewStateUserKey = value
/** @property */
public String get_ViewStateUserKey ()

/** @property */
public void set_ViewStateUserKey (String value)

public function get ViewStateUserKey () : String

public function set ViewStateUserKey (value : String)

Not applicable.

Property Value

The identifier for the individual user.

Exception typeCondition


The ViewStateUserKey property was accessed too late during page processing.

Setting the ViewStateUserKey property can help you prevent attacks on your application from malicious users. It does this by allowing you to assign an identifier to the view-state variable for individual users so that they cannot use the variable to generate an attack. You can set this property to any string value, such as the user's session ID or the user's authenticated name.


You must set this property during the Page_Init phase of page processing. Setting this property during the Page_Load phase throws an exception.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1