Share via


FormsAuthenticationConfiguration.Protection Propriété

Définition

Obtient ou définit le type de chiffrement utilisé pour chiffrer le 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

Valeur de propriété

Une des valeurs d'énumération FormsProtectionEnum. La valeur par défaut est All.

Note Veillez à utiliser la valeur par défaut pour cette propriété si vous souhaitez que la validation des données et le chiffrement aident à protéger le cookie. Cette option utilise l'algorithme de validation des données configurées basé sur machineKey. Triple DES (3DES) est utilisé pour le chiffrement, s’il est disponible et si la clé est suffisamment longue (48 octets ou plus).

Pour améliorer la protection de votre cookie, vous pouvez également affecter à RequireSSL la valeur true.

Attributs

Exemples

L'exemple de code suivant illustre l'accès à la propriété Protection. Reportez-vous à l’exemple de code dans la FormsAuthenticationConfiguration rubrique de classe pour savoir comment obtenir la section .

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

S’applique à

Voir aussi