ProfileMigrateEventArgs Klasse

Definition

Stellt Daten für das MigrateAnonymous-Ereignis der ProfileModule-Klasse bereit.

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

Beispiele

Die folgenden Codebeispiele zeigen eine Web.config Datei, die anonyme Authentifizierung und das MigrateAnonymous Ereignis in der Datei "Global.asax" für eine ASP.NET Anwendung ermöglicht.

Das folgende Codebeispiel zeigt eine Web.config Datei, die anonyme Identifizierungs- und Profileigenschaften ermöglicht, die anonyme Benutzer unterstützen.

<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>  

Das folgende Codebeispiel zeigt das Ereignis, das MigrateAnonymous in der Global.asax-Datei für eine ASP.NET Anwendung enthalten ist. Das MigrateAnonymous Ereignis kopiert Profileigenschaftenwerte aus dem anonymen Profil in das Profil für den aktuellen Benutzer.

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

Hinweise

Das ProfileMigrateEventArgs Objekt stellt Ereignisinformationen für das MigrateAnonymous Ereignis der ProfileModule Klasse bereit. Das ProfileMigrateEventArgs Objekt bietet Zugriff auf die HttpContext aktuelle Anforderung und den anonymen Benutzerbezeichner für das anonyme Profil in der AnonymousID Eigenschaft.

Sie können das Ereignis verwenden, um Profileigenschaftenwerte aus einem anonymen Profil in ein authentifiziertes Profil zu kopieren, wenn ein Benutzer, der MigrateAnonymous anonym Ihre Anwendungsprotokolle verwendet hat.

Wenn eine Anwendung mit aktiviertem Benutzerprofil gestartet wird, erstellt ASP.NET eine neue Klasse vom Typ ProfileCommon, die von der ProfileBase Klasse erbt. Wenn die Klasse generiert wird, basierend auf den profileigenschaften, die in der Web.config-Datei angegeben sind, wird eine GetProfile Methode hinzugefügt, mit der ProfileCommon Sie ein ProfileCommon Objekt basierend auf einem Benutzernamen abrufen können. Sie können die GetProfile Methode des aktuellen Profils verwenden, um die Eigenschaftswerte des anonymen Profils abzurufen. Die Werte der anonymen Eigenschaft können dann in das aktuelle Profil für den authentifizierten Benutzer kopiert werden.

Konstruktoren

ProfileMigrateEventArgs(HttpContext, String)

Erstellt eine Instanz der ProfileMigrateEventArgs-Klasse.

Eigenschaften

AnonymousID

Ruft den anonymen Bezeichner für das anonyme Profil ab, aus dem Profileigenschaftswerte migriert werden sollen.

Context

Ruft das HttpContext für die aktuelle Anforderung ab.

Methoden

Equals(Object)

Bestimmt, ob das angegebene Objekt gleich dem aktuellen Objekt ist.

(Geerbt von Object)
GetHashCode()

Fungiert als Standardhashfunktion.

(Geerbt von Object)
GetType()

Ruft den Type der aktuellen Instanz ab.

(Geerbt von Object)
MemberwiseClone()

Erstellt eine flache Kopie des aktuellen Object.

(Geerbt von Object)
ToString()

Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.

(Geerbt von Object)

Gilt für:

Siehe auch