ProfileMigrateEventArgs.AnonymousID Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan pengidentifikasi anonim untuk profil anonim untuk memigrasikan nilai properti profil.
public:
property System::String ^ AnonymousID { System::String ^ get(); };
public string AnonymousID { get; }
member this.AnonymousID : string
Public ReadOnly Property AnonymousID As String
Nilai Properti
Pengidentifikasi anonim untuk profil anonim untuk memigrasikan nilai properti profil.
Contoh
Contoh kode berikut menunjukkan file Web.config yang memungkinkan autentikasi anonim dan peristiwa yang MigrateAnonymous disertakan dalam file Global.asax untuk aplikasi ASP.NET
Contoh kode berikut menunjukkan file Web.config yang memungkinkan identifikasi anonim dan properti profil yang mendukung pengguna anonim.
<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>
Contoh kode berikut menunjukkan peristiwa yang MigrateAnonymous disertakan dalam file Global.asax untuk aplikasi ASP.NET. Peristiwa MigrateAnonymous menyalin nilai properti profil dari profil anonim ke profil untuk pengguna saat ini.
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
Keterangan
Properti AnonymousID berisi pengidentifikasi unik untuk pengguna anonim. Saat seseorang yang telah menggunakan aplikasi Anda masuk secara anonim, Anda dapat menangani MigrateAnonymous peristiwa untuk menyalin nilai properti profil dari profil anonim pengguna ke profil terautentikasi mereka.
Ketika aplikasi yang mengaktifkan profil pengguna dimulai, ASP.NET membuat kelas jenis ProfileCommon
baru , yang mewarisi dari ProfileBase kelas dan menyertakan properti profil yang ditentukan dalam file Web.config.
ProfileCommon
Saat kelas dibuat, GetProfile
metode ditambahkan yang memungkinkan Anda mengambil ProfileCommon
objek berdasarkan nama pengguna. Anda dapat menggunakan GetProfile
metode profil saat ini untuk mengambil nilai properti profil anonim. Nilai properti anonim kemudian dapat disalin ke profil saat ini untuk pengguna yang diautentikasi. Lihat contoh kode kedua untuk contoh menyalin nilai properti anonim.
Berlaku untuk
Lihat juga
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk