Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ProfileModule.Personalize Event

Occurs before the user profile is created.

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

public event ProfileEventHandler Personalize
/** @event */
public void add_Personalize (ProfileEventHandler value)

/** @event */
public void remove_Personalize (ProfileEventHandler value)

In JScript, you can handle the events defined by a class, but you cannot define your own.
Not applicable.

The Personalize event is raised during the HttpApplication.AcquireRequestState event. 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 ProfileEventArgs.Profile property value specified for the ProfileEventHandler event handler for the Personalize event is set to a value that is not a null reference (Nothing in Visual Basic) when the Personalize event ends, then the ProfileModule will use the specified value of the ProfileEventArgs.Profile property as the value of 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 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;
}

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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.