ProfileModule.MigrateAnonymous 이벤트

정의

프로필의 익명 사용자가 로그인할 때 발생합니다.

public:
 event System::Web::Profile::ProfileMigrateEventHandler ^ MigrateAnonymous;
public event System.Web.Profile.ProfileMigrateEventHandler MigrateAnonymous;
member this.MigrateAnonymous : System.Web.Profile.ProfileMigrateEventHandler 
Public Custom Event MigrateAnonymous As ProfileMigrateEventHandler 

이벤트 유형

예제

다음 예제에서는 익명 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

설명

액세스할 수 있습니다는 MigrateAnonymous 의 이벤트를 ProfileModule 클래스를 사용 하 여 ASP.NET 애플리케이션의 Global.asax 파일에는 Profile_MigrateAnonymous 이 항목의 예제에 표시 된 것 처럼 전역 이벤트.

사용할 수는 MigrateAnonymous 프로필 속성을 복사 하는 이벤트 값 익명 프로필에서 인증된 된 프로필에 익명으로 사용 하 여 애플리케이션 사용자가 로그인 할 때입니다.

사용자 프로필을 사용 하는 애플리케이션 시작 되 면 ASP.NET 형식의 새 클래스를 만듭니다 ProfileCommon에서 상속 되는 ProfileBase 클래스입니다. 강력한 형식의 접근자는 프로필> 구성 섹션에 ProfileCommon 정의된 각 속성의 클래스에 <추가됩니다. A GetProfile 메서드를 사용 하면 검색할는 ProfileCommon 사용자 이름을 기반으로 개체입니다. 사용할 수는 GetProfile 익명 프로필의 속성 값을 검색 하는 현재 인증 된 프로필의 메서드. 그런 다음 인증된 된 사용자에 대 한 현재 프로필에 익명 속성 값을 복사할 수 있습니다.

적용 대상

추가 정보