ProfileMigrateEventArgs.AnonymousID 속성

정의

프로필 속성 값을 마이그레이션할 익명 프로필에 대한 익명 식별자를 가져옵니다.

public:
 property System::String ^ AnonymousID { System::String ^ get(); };
public string AnonymousID { get; }
member this.AnonymousID : string
Public ReadOnly Property AnonymousID As String

속성 값

프로필 속성 값을 마이그레이션할 익명 프로필에 대한 익명 식별자입니다.

예제

다음 코드 예제에서는 익명 인증을 사용 하도록 설정 하는 Web.config 파일을 표시 하며 MigrateAnonymous ASP.NET 애플리케이션의 Global.asax 파일에 포함 된 이벤트

다음 코드 예제에서는 익명 id를 사용 하도록 설정 하는 Web.config 파일 및 익명 사용자를 지 원하는 프로필 속성을 보여 줍니다.

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

다음 코드 예제는 MigrateAnonymous ASP.NET 애플리케이션의 Global.asax 파일에 포함 된 이벤트입니다. MigrateAnonymous 이벤트 익명 프로필에서 현재 사용자의 프로필에 프로필 속성 값을 복사 합니다.

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

설명

AnonymousID 익명 사용자에 대 한 고유 식별자를 포함 하는 속성입니다. 애플리케이션을 사용 중인 사용자가 익명으로 로그인하면 이벤트를 처리 MigrateAnonymous 하여 사용자의 익명 프로필에서 인증된 프로필로 프로필 속성 값을 복사할 수 있습니다.

사용자 프로필을 사용 하는 애플리케이션 시작 되 면 ASP.NET 형식의 새 클래스를 만듭니다 ProfileCommon에서 상속 되는 ProfileBase 클래스 및 Web.config 파일에 지정 된 프로필 속성을 포함 합니다. 경우는 ProfileCommon 클래스가 생성 되는 GetProfile 검색할 수 있도록 메서드가 추가 됩니다을 ProfileCommon 개체 이름을 기반으로 사용자. 사용할 수는 GetProfile 메서드의 현재 프로필을 익명 프로필의 속성 값을 검색 합니다. 그런 다음 인증된 된 사용자에 대 한 현재 프로필에 익명 속성 값을 복사할 수 있습니다. 익명 속성 값을 복사의 예제에 대 한 두 번째 코드 예제를 참조 하세요.

적용 대상

추가 정보