Page.ViewStateUserKey 屬性

定義

在與目前網頁相關的檢視狀態變數中,指派識別項給個別的使用者。Assigns an identifier to an individual user in the view-state variable associated with the current page.

public:
 property System::String ^ ViewStateUserKey { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Browsable(false)]
public string ViewStateUserKey { get; set; }
member this.ViewStateUserKey : string with get, set
Public Property ViewStateUserKey As String

屬性值

個別使用者的識別項。The identifier for the individual user.

屬性

例外狀況

在網頁處理期間太晚存取 ViewStateUserKey 屬性。The ViewStateUserKey property was accessed too late during page processing.

備註

設定 ViewStateUserKey 屬性可協助您防止惡意使用者對應用程式的攻擊。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. 如需有關 Web 攻擊的詳細資訊,以及您可以如何預防它們的協助,請參閱利用 ASP.NET 的內建功能來至今尚未有人網路攻擊For more information about Web attacks and about what you can do to help prevent them, see Take Advantage of ASP.NET Built-in Features to Fend Off Web Attacks.

您可以將此屬性設定為任何字串值,例如使用者的已驗證名稱或 SessionID 值。You can set this property to any string value, such as the user's authenticated name or the SessionID value.

注意

您必須在頁面處理的 Page_Init 階段中設定這個屬性。You must set this property during the Page_Init phase of page processing. Page_Load 階段期間設定這個屬性會擲回例外狀況。Setting this property during the Page_Load phase throws an exception.

適用於

另請參閱