Share via


FormsAuthenticationConfiguration.Protection Propiedad

Definición

Obtiene o establece el tipo de cifrado que se utiliza para cifrar la 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

Valor de propiedad

Uno de los valores de enumeración de FormsProtectionEnum. El valor predeterminado es All.

Nota Asegúrese de usar el valor predeterminado para esta propiedad si desea que tanto la validación de datos como el cifrado ayuden a proteger la cookie. Esta opción utiliza el algoritmo de validación de datos configurado, que se basa en el elemento machineKey. Triple-DES (3DES) se usa para el cifrado, si está disponible y si la clave es suficientemente larga (48 bytes o más).

Para mejorar la protección de la cookie, quizás necesite establecer también la propiedad RequireSSL en true.

Atributos

Ejemplos

El siguiente ejemplo de código muestra cómo obtener acceso a la propiedad Protection. Consulte el ejemplo de código del tema de clase FormsAuthenticationConfiguration para obtener información sobre cómo obtener la sección .

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

Se aplica a

Consulte también