ProfileMigrateEventArgs Klasa

Definicja

Dostarcza dane dla MigrateAnonymous zdarzenia ProfileModule klasy.

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

Przykłady

W poniższych przykładach kodu przedstawiono plik Web.config, który umożliwia uwierzytelnianie anonimowe i MigrateAnonymous zdarzenie zawarte w pliku Global.asax dla aplikacji ASP.NET.

Poniższy przykład kodu przedstawia plik Web.config, który umożliwia anonimową identyfikację i właściwości profilu, które obsługują użytkowników anonimowych.

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

Poniższy przykład kodu przedstawia MigrateAnonymous zdarzenie zawarte w pliku Global.asax dla aplikacji ASP.NET. Zdarzenie MigrateAnonymous kopiuje wartości właściwości profilu z profilu anonimowego do profilu bieżącego użytkownika.

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

Uwagi

Obiekt ProfileMigrateEventArgs dostarcza informacje o MigrateAnonymous zdarzeniu ProfileModule klasy . Obiekt ProfileMigrateEventArgs zapewnia dostęp do HttpContext bieżącego żądania oraz identyfikatora użytkownika anonimowego dla profilu anonimowego AnonymousID we właściwości .

Zdarzenie służy MigrateAnonymous do kopiowania wartości właściwości profilu z profilu anonimowego do profilu uwierzytelnionego, gdy użytkownik, który był anonimowo przy użyciu logowania aplikacji.

Po uruchomieniu aplikacji z włączonym profilem użytkownika ASP.NET tworzy nową klasę typu ProfileCommon, która dziedziczy z ProfileBase klasy . Po wygenerowaniu ProfileCommon klasy na podstawie właściwości profilu określonych w pliku GetProfile Web.config zostanie dodana metoda umożliwiająca pobranie ProfileCommon obiektu na podstawie nazwy użytkownika. Możesz użyć GetProfile metody bieżącego profilu, aby pobrać wartości właściwości profilu anonimowego. Wartości właściwości anonimowych można następnie skopiować do bieżącego profilu dla uwierzytelnionego użytkownika.

Konstruktory

ProfileMigrateEventArgs(HttpContext, String)

Tworzy wystąpienie klasy ProfileMigrateEventArgs.

Właściwości

AnonymousID

Pobiera identyfikator anonimowy profilu anonimowego, z którego mają być migrowane wartości właściwości profilu.

Context

Pobiera element HttpContext dla bieżącego żądania.

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy

Zobacz też