Compartilhar via


FormsAuthenticationConfiguration.Protection Propriedade

Definição

Obtém ou define o tipo de criptografia usado para criptografar o 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 da propriedade

Um dos valores de FormsProtectionEnum enumeração. O valor padrão é All.

Nota Use o valor padrão dessa propriedade se desejar validação de dados e criptografia para ajudar a proteger o cookie. Essa opção usa o algoritmo de validação de dados configurado com base no machineKey. Triple-DES (3DES) é usado para criptografia, se disponível e se a chave for longa o suficiente (48 bytes ou mais).

Para melhorar a proteção do cookie, talvez você também queira definir como RequireSSLtrue.

Atributos

Exemplos

O exemplo de código a seguir mostra como acessar a Protection propriedade. Consulte o exemplo de código no tópico de FormsAuthenticationConfiguration classe para saber como obter a seção.

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

Aplica-se a

Confira também