FormsProtectionEnum 列舉

定義

定義 Cookie 使用的加密類型 (如果有的話)。

public enum class FormsProtectionEnum
public enum FormsProtectionEnum
type FormsProtectionEnum = 
Public Enum FormsProtectionEnum
繼承
FormsProtectionEnum

欄位

All 0

指定應用程式同時使用資料驗證與加密,以協助保護 Cookie。 這個選項會使用已設定的資料驗證演算法 (根據 machineKey 項目)。 如果可以使用三重 DES (3DES),且金鑰長度至少是 48 個位元組,則三重 DES (3DES) 會用於加密; All 為預設值 (同時也是建議值)。

Encryption 2

指定 Cookie 會使用三重 DES 或 DES 加密,但是資料驗證不會在 Cookie 上執行。 以這種方式使用的 Cookie 可能會受到所選擇的純文字安全性攻擊。

None 1

指定在只因為個人化理由使用 Cookie 而使得安全性要求較低的網站上停用加密和驗證。 不建議以這種方式使用 Cookie;不過,這是使用 .NET Framework 啟用個人化時最不耗用資源的方法。

Validation 3

指定應用程式使用驗證機制 (Scheme),以驗證加密 Cookie 的內容在傳送時沒有變更。 Cookie 的建立是藉由串連驗證金鑰和 Cookie 資料,計算訊息驗證程式碼 (Message Authentication Code,MAC),並將 MAC 附加於外送的 Cookie。

範例

下列範例示範如何使用 FormsProtectionEnum 列舉。 請參閱 類別中的 FormsAuthenticationConfiguration 程式碼範例,以瞭解如何取得 區段。

// Get the current Protection.
FormsProtectionEnum currentProtection = 
    formsAuthentication.Protection;

// Set the Protection property.
formsAuthentication.Protection = 
    FormsProtectionEnum.All;
' Get the current Protection.
  Dim currentProtection As FormsProtectionEnum = _
  formsAuthentication.Protection

' Set the Protection property.
formsAuthentication.Protection = FormsProtectionEnum.All

備註

如果您選取 All 值,系統會根據 machineKey 標籤使用已設定的資料驗證演算法。 這是預設值和建議的值。

如果您選取 None ,Cookie 可能會受到純文字攻擊。

如果您選取 Validation ,則會使用 Cookie 驗證來建立 Cookie 驗證,方法是串連驗證金鑰與 Cookie 資料、計算訊息驗證碼 (MAC) ,並將 MAC 附加至傳出 Cookie。

適用於

另請參閱