ProfileModule.MigrateAnonymous Olay

Tanım

Profil için anonim kullanıcı oturum açtığında gerçekleşir.

public:
 event System::Web::Profile::ProfileMigrateEventHandler ^ MigrateAnonymous;
public event System.Web.Profile.ProfileMigrateEventHandler MigrateAnonymous;
member this.MigrateAnonymous : System.Web.Profile.ProfileMigrateEventHandler 
Public Custom Event MigrateAnonymous As ProfileMigrateEventHandler 

Olay Türü

Örnekler

Aşağıdaki örnekte anonim kullanıcıları destekleyen anonim kimlik ve profil özelliklerini etkinleştiren bir Web.config dosyası gösterilmektedir.

<configuration>  
  <system.web>  
    <authentication mode="Forms" >  
      <forms loginUrl="login.aspx" name=".ASPXFORMSAUTH" />  
    </authentication>  

    <anonymousIdentification enabled="true" />  

    <profile enabled="true" defaultProvider="AspNetSqlProvider">  
      <properties>  
        <add name="ZipCode" allowAnonymous="true" />  
        <add name="CityAndState" allowAnonymous="true" />  
        <add name="StockSymbols" type="System.Collections.ArrayList" allowAnonymous="true" />  
      </properties>  
    </profile>  
  </system.web>  
</configuration>  

Aşağıdaki kod örneği, bir ASP.NET uygulamasının Global.asax dosyasına dahil edilen olayı gösterir MigrateAnonymous . Olay, MigrateAnonymous profil özelliği değerlerini anonim profilden geçerli kullanıcının profiline kopyalar.

public void Profile_OnMigrateAnonymous(object sender, ProfileMigrateEventArgs args)
{
  ProfileCommon anonymousProfile = Profile.GetProfile(args.AnonymousID);

  Profile.ZipCode = anonymousProfile.ZipCode;
  Profile.CityAndState = anonymousProfile.CityAndState;
  Profile.StockSymbols = anonymousProfile.StockSymbols;

  ////////
  // Delete the anonymous profile. If the anonymous ID is not 
  // needed in the rest of the site, remove the anonymous cookie.

  ProfileManager.DeleteProfile(args.AnonymousID);
  AnonymousIdentificationModule.ClearAnonymousIdentifier(); 

  // Delete the user row that was created for the anonymous user.
  Membership.DeleteUser(args.AnonymousID, true);

}
Public Sub Profile_OnMigrateAnonymous(sender As Object, args As ProfileMigrateEventArgs)
  Dim anonymousProfile As ProfileCommon = Profile.GetProfile(args.AnonymousID)

  Profile.ZipCode = anonymousProfile.ZipCode
  Profile.CityAndState = anonymousProfile.CityAndState
  Profile.StockSymbols = anonymousProfile.StockSymbols

  ''''''''
  ' Delete the anonymous profile. If the anonymous ID is not 
  ' needed in the rest of the site, remove the anonymous cookie.

  ProfileManager.DeleteProfile(args.AnonymousID)
  AnonymousIdentificationModule.ClearAnonymousIdentifier()

  ' Delete the user row that was created for the anonymous user.
  Membership.DeleteUser(args.AnonymousID, True)
End Sub

Açıklamalar

Bu konudaki örnekte gösterildiği gibi genel olayı kullanarak ASP.NET uygulamanızın Profile_MigrateAnonymous Global.asax dosyasında sınıfının olayına ProfileModule erişebilirsinizMigrateAnonymous.

Uygulamanızı anonim olarak kullanan bir kullanıcı oturum açtığında, profil özelliği değerlerini anonim profilden kimliği doğrulanmış bir profile kopyalamak için olayını kullanabilirsiniz MigrateAnonymous .

Kullanıcı profili etkinleştirilmiş bir uygulama başlatıldığında, ASP.NET sınıfından ProfileBase devralan yeni bir tür ProfileCommonsınıfı oluşturur. Kesin türü belirlenmiş erişimciler, profil> yapılandırması bölümünde tanımlanan her özellik için sınıfına <eklenirProfileCommon. GetProfile Yöntem, kullanıcı adına göre bir ProfileCommon nesne almanıza olanak tanır. Anonim profilin GetProfile özellik değerlerini almak için geçerli, kimliği doğrulanmış profilin yöntemini kullanabilirsiniz. Anonim özellik değerleri daha sonra kimliği doğrulanmış kullanıcının geçerli profiline kopyalanabilir.

Şunlara uygulanır

Ayrıca bkz.