ProfileMigrateEventHandler 代理人

定義

MigrateAnonymous クラスの ProfileModule イベントを処理するメソッドを表します。

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)

パラメーター

sender
Object

ProfileModule イベントの発生元の MigrateAnonymous

e
ProfileMigrateEventArgs

イベント データを格納している ProfileMigrateEventArgs

次のコード例は、匿名認証を有効にする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

注釈

デリゲートは ProfileMigrateEventHandler 、 クラスの イベントに対して MigrateAnonymous 定義されます ProfileModule 。 このトピックのProfileModule例に示すように、ASP.NET アプリケーションの Global.asax ファイル内の クラスのイベントにアクセスMigrateAnonymousできます。

イベントを MigrateAnonymous 使用すると、アプリケーションを匿名で使用しているユーザーがログインしたときに、プロファイル プロパティの値を匿名プロファイルから認証済みプロファイルにコピーできます。

ユーザー プロファイルが有効になっているアプリケーションを起動すると、ASP.NET は、 クラスから継承する 型 ProfileCommonの新しいクラスを ProfileBase 作成します。 クラスが ProfileCommon 生成されると、Web.config ファイルで指定されたプロファイル プロパティに基づいて、 GetProfile ユーザー名に基づいてオブジェクトを取得 ProfileCommon できる メソッドが追加されます。 現在のプロファイルの GetProfile メソッドを使用して、匿名プロファイルのプロパティ値を取得できます。 匿名プロパティの値は、認証されたユーザーの現在のプロファイルにコピーできます。

拡張メソッド

GetMethodInfo(Delegate)

指定したデリゲートによって表されるメソッドを表すオブジェクトを取得します。

適用対象

こちらもご覧ください