ProfileEventArgs Klasa

Definicja

Dostarcza dane dla Personalize zdarzenia ProfileModule klasy.

public ref class ProfileEventArgs sealed : EventArgs
public sealed class ProfileEventArgs : EventArgs
type ProfileEventArgs = class
    inherit EventArgs
Public NotInheritable Class ProfileEventArgs
Inherits EventArgs
Dziedziczenie
ProfileEventArgs

Przykłady

Poniższy przykład kodu przedstawia Personalize zdarzenie zadeklarowane w pliku Global.asax dla aplikacji. Kod zdarzenia ładuje profil użytkownika na podstawie członkostwa w rolach.

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

Uwagi

Możesz użyć ProfileEventArgs klasy podczas Personalize zdarzenia, aby określić niestandardowy profil użytkownika. Jeśli po zakończeniu PersonalizeProfileEventArgs zdarzenia parametr ProfileEventHandler obiektu ma właściwość Profile ustawioną na wartość nullinną niż , ProfileModule parametr używa wartości Profile właściwości w bieżącym HttpContextobiekcie .

Konstruktory

ProfileEventArgs(HttpContext)

Tworzy wystąpienie klasy ProfileEventArgs.

Właściwości

Context

Pobiera element HttpContext dla bieżącego żądania.

Profile

Pobiera lub ustawia profil użytkownika dla bieżącego żądania.

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy

Zobacz też