ProfileEventArgs Classe

Definição

Fornece dados para o evento Personalize da classe ProfileModule.Provides data for the Personalize event of the ProfileModule class.

public ref class ProfileEventArgs sealed : EventArgs
public sealed class ProfileEventArgs : EventArgs
type ProfileEventArgs = class
    inherit EventArgs
Public NotInheritable Class ProfileEventArgs
Inherits EventArgs
Herança
ProfileEventArgs

Exemplos

O exemplo de código a seguir mostra o Personalize evento declarado no arquivo global. asax para um aplicativo.The following code example shows the Personalize event declared in the Global.asax file for an application. O código do evento carrega um perfil de usuário com base na associação de função.The event code loads a user profile based on role membership.

public void Profile_Personalize(object sender, ProfileEventArgs args)
{
  ProfileCommon userProfile;

  if (User == null) { return; }

  userProfile = (ProfileCommon)ProfileBase.Create(User.Identity.Name);

  if (User.IsInRole("Administrators"))
    userProfile = userProfile.GetProfile("Administrator");
  else
    if (User.IsInRole("Users"))
      userProfile = userProfile.GetProfile("User");
    else
      userProfile = userProfile.GetProfile("Guest");

  if (userProfile != null)
    args.Profile = userProfile;
}
Public Sub Profile_Personalize(sender As Object, args As ProfileEventArgs)
  Dim userProfile As ProfileCommon

  If User Is Nothing Then Return

  userProfile = CType(ProfileBase.Create(User.Identity.Name), ProfileCommon)

  If User.IsInRole("Administrators") Then
    userProfile = userProfile.GetProfile("Administrator")
  Else
    If User.IsInRole("Users") Then
      userProfile = userProfile.GetProfile("User")
    Else
      userProfile = userProfile.GetProfile("Guest")
    End If
  End If

  If Not userProfile Is Nothing Then _
    args.Profile = userProfile
End Sub

Comentários

Você pode usar a ProfileEventArgs classe durante o Personalize evento para especificar um perfil de usuário personalizado.You can use the ProfileEventArgs class during the Personalize event to specify a custom user profile. Se, quando o Personalize evento for concluído, o ProfileEventArgs parâmetro de ProfileEventHandler tiver sua Profile propriedade definida como um valor que não é null , o ProfileModule usará o valor da Profile propriedade no atual HttpContext .If, when the Personalize event completes, the ProfileEventArgs parameter of the ProfileEventHandler has its Profile property set to a value that's not null, then the ProfileModule uses the value of the Profile property in the current HttpContext.

Construtores

ProfileEventArgs(HttpContext)

Cria uma instância de ProfileEventArgs classe.Creates an instance of the ProfileEventArgs class.

Propriedades

Context

Obtém o HttpContext da solicitação atual.Gets the HttpContext for the current request.

Profile

Obtém ou define o perfil do usuário para a solicitação atual.Gets or sets the user profile for the current request.

Métodos

Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object.

(Herdado de Object)
GetHashCode()

Serve como a função de hash padrão.Serves as the default hash function.

(Herdado de Object)
GetType()

Obtém o Type da instância atual.Gets the Type of the current instance.

(Herdado de Object)
MemberwiseClone()

Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object.

(Herdado de Object)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object.

(Herdado de Object)

Aplica-se a