Page.ViewStateEncryptionMode 屬性


取得或設定檢視狀態的加密模式。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



其中一個 ViewStateEncryptionMode 值。One of the ViewStateEncryptionMode values. 預設值是 AutoThe default value is Auto.



設定值不是 ViewStateEncryptionMode 列舉型別的成員。The value set is not a member of the ViewStateEncryptionMode enumeration.

只有在頁面生命週期的頁面 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.