Page.ViewStateEncryptionMode Page.ViewStateEncryptionMode Page.ViewStateEncryptionMode Page.ViewStateEncryptionMode Property


取得或設定檢視狀態的加密模式。Gets or sets the encryption mode of the view state.

 property System::Web::UI::ViewStateEncryptionMode ViewStateEncryptionMode { System::Web::UI::ViewStateEncryptionMode get(); void set(System::Web::UI::ViewStateEncryptionMode value); };
public System.Web.UI.ViewStateEncryptionMode ViewStateEncryptionMode { get; set; }
member this.ViewStateEncryptionMode : System.Web.UI.ViewStateEncryptionMode with get, set
Public Property ViewStateEncryptionMode As ViewStateEncryptionMode



只有在頁面生命週期的頁面 PreRender 階段期間或之前,才能設定 ViewStateEncryptionMode 屬性。The ViewStateEncryptionMode property can be set only in or before the page PreRender phase in the page life cycle.


ViewStateEncryptionMode無法在程式碼中設定屬性。The ViewStateEncryptionMode property cannot be set in code. 它可以只在中設定@ Page指示詞或在 < 組態檔的項目。It can only be set in the @ Page directive or in the < element of the configuration file. 設定的值@ Page指示詞覆寫組態檔中設定的任何值。Values set in the @ Page directive override any values set in the configuration file.

設定這個屬性的語法@ Page指示詞時,如下所示:The syntax for setting this property in the @ Page directive is as follows:

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

在組態檔中設定這個屬性的語法如下所示:The syntax for setting this property in the configuration file is as follows:

  <pages viewStateEncryptionMode="Always" />  
  <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.