Uređivanje

Dijeli putem


ProfileEventArgs Class

Definition

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
Inheritance
ProfileEventArgs

Examples

The following code example shows the Personalize event declared in the Global.asax file for an application. 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

Remarks

You can use the ProfileEventArgs class during the Personalize event to specify a custom user profile. 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.

Constructors

ProfileEventArgs(HttpContext)

Creates an instance of the ProfileEventArgs class.

Properties

Context

Gets the HttpContext for the current request.

Profile

Gets or sets the user profile for the current request.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also