FormsAuthenticationConfiguration.Protection Propriedade

Definição

Obtém ou define o tipo de encriptação usado para encriptar 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 de Propriedade

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

Nota Certifique-se de usar o valor padrão desta propriedade se quiser validação de dados e encriptação para ajudar a proteger o cookie. Esta opção utiliza o algoritmo de validação de dados configurado baseado no machineKey. Triple-DES (3DES) é usado para encriptação, se disponível e se a chave for suficientemente longa (48 bytes ou mais).

Para melhorar a proteção do seu cookie, pode também querer definir o RequireSSL .true

Atributos

Exemplos

O seguinte exemplo de código mostra como aceder à Protection propriedade. Consulta o exemplo do código no FormsAuthenticationConfiguration tópico da aula para saberes como obter a secçã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

Ver também