Share via


FormsAuthenticationConfiguration.Protection Eigenschaft

Definition

Ruft den Verschlüsselungstyp für das Verschlüsseln des Cookies ab oder legt diesen fest.

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

Eigenschaftswert

Einer der FormsProtectionEnum-Enumerationswerte. Der Standardwert ist All.

Hinweis Achten Sie darauf, den Standardwert für diese Eigenschaft zu verwenden, wenn Sie möchten, dass sowohl die Datenüberprüfung als auch die Verschlüsselung zum Schutz des Cookies beitragen. Diese Option verwendet den konfigurierten Datenvalidierungsalgorithmus auf der Grundlage des machineKey. Für die Verschlüsselung wird Triple-DES (3DES) verwendet, wenn dieser Algorithmus verfügbar und der Schlüssel lang genug (mindestens 48 Bytes) ist.

Um den Schutz des Cookies zu erhöhen, können Sie außerdem RequireSSL auf true festlegen.

Attribute

Beispiele

Im folgenden Codebeispiel wird der Zugriff auf die Protection-Eigenschaft veranschaulicht. Lesen Sie das Codebeispiel im FormsAuthenticationConfiguration Klassenthema, um zu erfahren, wie Sie den Abschnitt abrufen.

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

Gilt für:

Weitere Informationen