Condividi tramite


FormsAuthenticationConfiguration.Protection Proprietà

Definizione

Ottiene o imposta il tipo di crittografia utilizzato per crittografare il cookie.

public:
 property System::Web::Configuration::FormsProtectionEnum Protection { System::Web::Configuration::FormsProtectionEnum get(); void set(System::Web::Configuration::FormsProtectionEnum value); };
[System.Configuration.ConfigurationProperty("protection", DefaultValue=System.Web.Configuration.FormsProtectionEnum.All)]
public System.Web.Configuration.FormsProtectionEnum Protection { get; set; }
[<System.Configuration.ConfigurationProperty("protection", DefaultValue=System.Web.Configuration.FormsProtectionEnum.All)>]
member this.Protection : System.Web.Configuration.FormsProtectionEnum with get, set
Public Property Protection As FormsProtectionEnum

Valore della proprietà

Uno dei valori di FormsProtectionEnum enumerazione. Il valore predefinito è All.

Nota Assicurarsi di usare il valore predefinito per questa proprietà se si vuole che la convalida dei dati e la crittografia consentano di proteggere il cookie. Questa opzione usa l'algoritmo di convalida dei dati configurato basato su machineKey. Triple-DES (3DES) viene usato per la crittografia, se disponibile e se la chiave è sufficientemente lunga (48 byte o più).

Per migliorare la protezione del cookie, è anche possibile impostare su RequireSSLtrue.

Attributi

Esempio

Nell'esempio di codice seguente viene illustrato come accedere alla Protection proprietà . Fare riferimento all'esempio di codice nell'argomento della FormsAuthenticationConfiguration classe per informazioni su come ottenere la sezione .

// 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

Si applica a

Vedi anche