PagesSection.EnableViewStateMac 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定一個值,指定 ASP.NET 在頁面從用戶端回傳時,是否應該對頁面的檢視狀態執行訊息驗證碼(MAC)。
public:
property bool EnableViewStateMac { bool get(); void set(bool value); };
[System.Configuration.ConfigurationProperty("enableViewStateMac", DefaultValue=true)]
public bool EnableViewStateMac { get; set; }
[<System.Configuration.ConfigurationProperty("enableViewStateMac", DefaultValue=true)>]
member this.EnableViewStateMac : bool with get, set
Public Property EnableViewStateMac As Boolean
屬性值
true如果 ASP.NET 在頁面從用戶端回傳頁面時,應該執行訊息認證碼(MAC);否則,。 false 預設值為 true。
- 屬性
範例
以下程式碼範例說明如何使用該 EnableViewStateMac 屬性。
// Get the current EnableViewStateMac property value.
Console.WriteLine(
"Current EnableViewStateMac value: '{0}'",
pagesSection.EnableViewStateMac);
// Set the EnableViewStateMac property to true.
pagesSection.EnableViewStateMac = true;
' Get the current EnableViewStateMac property value.
Console.WriteLine( _
"Current EnableViewStateMac value: '{0}'", _
pagesSection.EnableViewStateMac)
' Set the EnableViewStateMac property to true.
pagesSection.EnableViewStateMac = True
備註
視圖狀態 MAC 是頁面被傳送到瀏覽器時,隱藏變數的加密版本,該變數會持久化到該變數。 當此屬性設為 true時,會檢查加密檢視狀態是否在用戶端被竄改。
這很重要
即使應用程式或頁面不使用檢視狀態,這個屬性在生產網站上絕不應被設定為false 視圖狀態 MAC 有助於確保除了視圖狀態外,其他 ASP.NET 函式的安全性。