ProfileMigrateEventHandler Delegat
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Stellt die Methode dar, die das MigrateAnonymous Ereignis der ProfileModule Klasse behandelt.
public delegate void ProfileMigrateEventHandler(System::Object ^ sender, ProfileMigrateEventArgs ^ e);
public delegate void ProfileMigrateEventHandler(object sender, ProfileMigrateEventArgs e);
type ProfileMigrateEventHandler = delegate of obj * ProfileMigrateEventArgs -> unit
Public Delegate Sub ProfileMigrateEventHandler(sender As Object, e As ProfileMigrateEventArgs)
Parameter
- sender
- Object
Das ProfileModule Ereignis wurde ausgelöst MigrateAnonymous .
Ein ProfileMigrateEventArgs Objekt, das die Ereignisdaten enthält.
Beispiele
Die folgenden Codebeispiele zeigen eine Web.config Datei, die anonyme Authentifizierung und das Ereignis ermöglicht, das MigrateAnonymous in der Datei "Global.asax" für eine ASP.NET Anwendung enthalten ist.
Das folgende Codebeispiel zeigt eine Web.config Datei, die anonyme Identifikations- 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 Datei "Global.asax" 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
Der Delegat ProfileMigrateEventHandler wird für das MigrateAnonymous Ereignis der ProfileModule Klasse definiert. Sie können auf das ereignis MigrateAnonymous der Klasse ProfileModule in der Datei "Global.asax" für Ihre ASP.NET Anwendung zugreifen, wie im Beispiel für dieses Thema gezeigt.
Sie können das MigrateAnonymous Ereignis verwenden, um Profileigenschaftenwerte aus einem anonymen Profil in ein authentifiziertes Profil zu kopieren, wenn jemand, der 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 ProfileCommon Klasse basierend auf den in der Web.config Datei angegebenen Profileigenschaften generiert wird, wird eine GetProfile Methode hinzugefügt, mit der Sie ein ProfileCommon Objekt basierend auf einem Benutzernamen abrufen können. Mit der GetProfile Methode des aktuellen Profils können Sie die Eigenschaftswerte des anonymen Profils abrufen. Die Werte der anonymen Eigenschaft können dann in das aktuelle Profil für den authentifizierten Benutzer kopiert werden.
Erweiterungsmethoden
| Name | Beschreibung |
|---|---|
| GetMethodInfo(Delegate) |
Ruft ein Objekt ab, das die vom angegebenen Delegaten dargestellte Methode darstellt. |