ProfileEventArgs.Profile Özellik

Tanım

Geçerli istek için kullanıcı profilini alır veya ayarlar.

public:
 property System::Web::Profile::ProfileBase ^ Profile { System::Web::Profile::ProfileBase ^ get(); void set(System::Web::Profile::ProfileBase ^ value); };
public System.Web.Profile.ProfileBase Profile { get; set; }
member this.Profile : System.Web.Profile.ProfileBase with get, set
Public Property Profile As ProfileBase

Özellik Değeri

Geçerli istek için kullanılacak kullanıcı profili. Varsayılan değer: null.

Örnekler

Aşağıdaki kod örneği, bir uygulama için Global.asax dosyasında bildirilen olayı gösterir Personalize . Olay kodu, rol üyeliğine göre bir kullanıcı profili yükler.

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

Açıklamalar

Özel bir kullanıcı profili belirtmek için olay sırasında Profile özelliğini kullanabilirsinizPersonalize. Olay tamamlandığında Personalize parametresinin ProfileEventArgsProfileEventHandler özelliği olmayan bir değere Profilenull ayarlanmışsa, geçerli içindeki ProfileModuleözelliğinin Profile değerini kullanır.HttpContext

Note

, ProfileModule olayın özelliğini Profile ayarlamazPersonalize. yalnızca ProfileModule olaydaki kod tamamlandığında özelliğinin Profile değerini Personalize alır. ProfileEventArgs.Profile Özellik, olay sırasında Personalize uygulama kodu tarafından açıkça ayarlanmadıysa, Profile özellik değeri olurnull.

Şunlara uygulanır

Ayrıca bkz.