ProfileMigrateEventHandler Delegera
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Representerar den metod som ska hantera MigrateAnonymous händelsen för ProfileModule klassen.
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)
Parametrar
- sender
- Object
Det ProfileModule som väckte händelsen MigrateAnonymous .
En ProfileMigrateEventArgs som innehåller händelsedata.
Exempel
Följande kodexempel visar en Web.config fil som möjliggör anonym autentisering och händelsen MigrateAnonymous som ingår i filen Global.asax för ett ASP.NET program.
I följande kodexempel visas en Web.config fil som möjliggör anonym identifiering och profilegenskaper som stöder anonyma användare.
<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>
I följande kodexempel visas händelsen MigrateAnonymous som ingår i filen Global.asax för ett ASP.NET program. Händelsen MigrateAnonymous kopierar profilegenskapsvärden från den anonyma profilen till profilen för den aktuella användaren.
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
Kommentarer
Ombudet ProfileMigrateEventHandler definieras för MigrateAnonymous händelsen för ProfileModule klassen. Du kan komma åt händelsen MigrateAnonymous för klassen ProfileModule i filen Global.asax för ditt ASP.NET-program enligt exemplet för det här avsnittet.
Du kan använda händelsen för att kopiera profilegenskapsvärden från en anonym profil till en autentiserad MigrateAnonymous profil när någon som har använt dina programloggar anonymt.
När ett program som har användarprofilen aktiverad startas skapar ASP.NET en ny klass av typen ProfileCommon, som ärver från klassen ProfileBase.
ProfileCommon När klassen genereras, baserat på profilegenskaperna som anges i filen Web.config, läggs en GetProfile metod till som gör att du kan hämta ett ProfileCommon objekt baserat på ett användarnamn. Du kan använda metoden för GetProfile den aktuella profilen för att hämta egenskapsvärdena för den anonyma profilen. De anonyma egenskapsvärdena kan sedan kopieras till den aktuella profilen för den autentiserade användaren.
Tilläggsmetoder
| Name | Description |
|---|---|
| GetMethodInfo(Delegate) |
Hämtar ett objekt som representerar den metod som representeras av det angivna ombudet. |