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.

 property bool EnableViewStateMac { bool get(); void set(bool value); };
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. 設定EnableViewStateMac屬性使用@ Page .aspx 檔案中的指示詞。Set 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. 檢視狀態 MAC 可協助確保其他 ASP.NET 函式,除了檢視狀態的安全性。The view state MAC helps ensure the security of other ASP.NET functions in addition to view state.