Page.EnableViewStateMac Page.EnableViewStateMac Page.EnableViewStateMac Page.EnableViewStateMac Property

定義

取得或設定值,這個值表示從用戶端回傳網頁時,ASP.NET 是否應該檢查網頁檢視狀態中的訊息驗證碼 (MAC)。Gets or sets a value indicating whether ASP.NET should check message authentication codes (MAC) in the page's view state when the page is posted back from the client.

public:
 property bool EnableViewStateMac { bool get(); void set(bool value); };
[System.ComponentModel.Browsable(false)]
public bool EnableViewStateMac { get; set; }
member this.EnableViewStateMac : bool with get, set
Public Property EnableViewStateMac As Boolean

屬性值

如果應該對檢視狀態執行 MAC 檢查和編碼,則為 true,否則為 falsetrue if the view state should be MAC checked and encoded; otherwise, false. 預設為 trueThe default is true.

備註

「檢視狀態」 MAC 是隱藏變數的加密版本,當頁面傳送至瀏覽器時,頁面的檢視狀態會保存到其中。A view-state MAC is an encrypted version of the hidden variable that a page's view state is persisted to when the page is sent to the browser. 當這個屬性設定為true時,系統會檢查加密的檢視狀態,以確認它在用戶端上未遭到篡改。When this property is set to true, the encrypted view state is checked to verify that it has not been tampered with on the client.

請勿在程式碼中設定此屬性。Do not set this property in code. 使用 .aspx 檔案中的@ Page指示詞來設定屬性。EnableViewStateMacSet the EnableViewStateMac attribute using the @ Page directive in the .aspx file. 當要求頁面時,動態產生的類別會設定屬性。When the page is requested, the dynamically generated class sets the property.

重要

即使應用程式或頁面不使用false檢視狀態,也不應該在生產網站中將這個屬性設定為。This attribute should never be set to false in a production Web site, even if the application or page does not use view state. 除了 view 狀態以外,檢視狀態 MAC 有助於確保其他 ASP.NET 功能的安全性。The view state MAC helps ensure the security of other ASP.NET functions in addition to view state.

適用於

另請參閱