ProfileEventArgs ProfileEventArgs ProfileEventArgs ProfileEventArgs Class

Definición

Proporciona datos para el evento Personalize de la clase 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
Herencia
ProfileEventArgsProfileEventArgsProfileEventArgsProfileEventArgs

Ejemplos

El siguiente ejemplo de código muestra la Personalize evento declarado en el archivo Global.asax para una aplicación.The following code example shows the Personalize event declared in the Global.asax file for an application. El código de evento carga un perfil de usuario según la pertenencia al rol.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

Comentarios

Puede usar el ProfileEventArgs clase durante la Personalize eventos para especificar un perfil de usuario personalizado.You can use the ProfileEventArgs class during the Personalize event to specify a custom user profile. If, cuando el Personalize evento se complete, el ProfileEventArgs parámetro de la ProfileEventHandler tiene su Profile propiedad establecida en un valor que no es null, el ProfileModule usa el valor de la Profile propiedad actual 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.

Constructores

ProfileEventArgs(HttpContext) ProfileEventArgs(HttpContext) ProfileEventArgs(HttpContext) ProfileEventArgs(HttpContext)

Crea una instancia de la clase ProfileEventArgs.Creates an instance of the ProfileEventArgs class.

Propiedades

Context Context Context Context

Obtiene el valor de la clase HttpContext para la solicitud actual.Gets the HttpContext for the current request.

Profile Profile Profile Profile

Obtiene o establece el perfil de usuario para la solicitud actual.Gets or sets the user profile for the current request.

Métodos

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina si el objeto especificado es igual al objeto actual.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Sirve como la función hash predeterminada.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficial del objeto Object actual.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

(Inherited from Object)

Se aplica a

Consulte también: