ProfileMigrateEventArgs Kelas

Definisi

Menyediakan data untuk MigrateAnonymous peristiwa ProfileModule kelas.

public ref class ProfileMigrateEventArgs sealed : EventArgs
public sealed class ProfileMigrateEventArgs : EventArgs
type ProfileMigrateEventArgs = class
    inherit EventArgs
Public NotInheritable Class ProfileMigrateEventArgs
Inherits EventArgs
Warisan
ProfileMigrateEventArgs

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

Objek ProfileMigrateEventArgs menyediakan informasi peristiwa untuk MigrateAnonymous peristiwa ProfileModule kelas. Objek ProfileMigrateEventArgs menyediakan akses ke HttpContext permintaan saat ini dan pengidentifikasi pengguna anonim untuk profil anonim di AnonymousID properti .

Anda dapat menggunakan peristiwa tersebut MigrateAnonymous untuk menyalin nilai properti profil dari profil anonim ke profil terautentikasi saat pengguna yang secara anonim menggunakan aplikasi Anda masuk.

Ketika aplikasi yang mengaktifkan profil pengguna dimulai, ASP.NET membuat kelas jenis ProfileCommonbaru , yang mewarisi dari ProfileBase kelas . ProfileCommon Saat kelas dibuat, berdasarkan properti profil yang ditentukan dalam file Web.config, 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.

Konstruktor

ProfileMigrateEventArgs(HttpContext, String)

Membuat instans ProfileMigrateEventArgs kelas .

Properti

AnonymousID

Mendapatkan pengidentifikasi anonim untuk profil anonim untuk memigrasikan nilai properti profil.

Context

HttpContext Mendapatkan untuk permintaan saat ini.

Metode

Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetType()

Mendapatkan dari instans Type saat ini.

(Diperoleh dari Object)
MemberwiseClone()

Membuat salinan dangkal dari saat ini Object.

(Diperoleh dari Object)
ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Berlaku untuk

Lihat juga