FormsAuthenticationConfiguration.Protection Egenskap

Definition

Hämtar eller anger den krypteringstyp som används för att kryptera cookien.

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

Egenskapsvärde

Ett av uppräkningsvärdena FormsProtectionEnum . Standardvärdet är All.

Observera Se till att använda standardvärdet för den här egenskapen om du vill att både dataverifiering och kryptering ska hjälpa till att skydda cookien. Det här alternativet använder den konfigurerade algoritmen machineKeyför dataverifiering baserat på . Triple-DES (3DES) används för kryptering, om det är tillgängligt och om nyckeln är tillräckligt lång (48 byte eller mer).

För att förbättra skyddet av din cookie kanske du också vill ange RequireSSL till true.

Attribut

Exempel

Följande kodexempel visar hur du kommer åt egenskapen Protection . Se kodexemplet i klassavsnittet FormsAuthenticationConfiguration för att lära dig hur du hämtar avsnittet.

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

Gäller för

Se även