ProfileModule.MigrateAnonymous Olay
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
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 tanımlama 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
ASP.NET uygulamanızın Global.asax dosyasındaki MigrateAnonymous sınıfının ProfileModule olayına, bu konudaki örnekte gösterildiği gibi Profile_MigrateAnonymous genel olayını kullanarak erişebilirsiniz.
Uygulamanızı anonim olarak kullanan bir kullanıcı oturum açtığında, anonim profilden kimliği doğrulanmış bir profile profil özelliği değerlerini kopyalamak için olayını kullanabilirsiniz MigrateAnonymous .
Kullanıcı profili etkinleştirilmiş bir uygulama başlatıldığında, ASP.NET sınıfından ProfileCommon devralan yeni bir tür ProfileBasesınıfı oluşturur. Kesin olarak belirlenmiş erişimciler, profilProfileCommon yapılandırması bölümünde tanımlanan her özellik için sınıfına <eklenir>.
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.