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.


無法在程式碼中設定屬性。ViewStateEncryptionModeThe 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.