This documentation is archived and is not being maintained.

ProfileEventHandler Delegate

Represents the method that will handle the Personalize event of a ProfileModule.

Namespace:  System.Web.Profile
Assembly:  System.Web (in System.Web.dll)

'Declaration
Public Delegate Sub ProfileEventHandler ( _
	sender As Object, _
	e As ProfileEventArgs _
)
'Usage
Dim instance As New ProfileEventHandler(AddressOf HandlerMethod)

Parameters

sender
Type: System.Object

The ProfileModule that raised the Personalize event.

e
Type: System.Web.Profile.ProfileEventArgs

A ProfileEventArgs that contains the event data.

The ProfileEventHandler delegate is defined for the Personalize event of the ProfileModule class. You can access the Personalize event of the ProfileModule class in the Global.asax file for your ASP.NET application using the Profile_Personalize global event, as shown in the example for this topic.

You can use the Personalize event to specify a custom user profile. If the Profile property of the ProfileEventArgs parameter specified for the Personalize event's ProfileEventHandler is set to a non-null value when the Personalize event completes, then the ProfileModule will use that value for the Profile property of the current HttpContext.

The following code example shows the Personalize event declared in the Global.asax file for an application. The event code loads a user profile for a user based on role membership.

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

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Show: