ProfileMigrateEventHandler 代理人
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
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。
イベント データを含む ProfileMigrateEventArgs 。
例
次のコード例は、匿名認証を有効にする Web.config ファイルと、ASP.NET アプリケーションの Global.asax ファイルに含まれる MigrateAnonymous イベントを示しています。
次のコード例は、匿名ユーザーをサポートする匿名 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>
次のコード例は、ASP.NET アプリケーションの Global.asax ファイルに含まれる MigrateAnonymous イベントを示しています。 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 イベントに対して定義されます。 このトピックの例に示すように、ASP.NET アプリケーションの Global.asax ファイル内の ProfileModule クラスの MigrateAnonymous イベントにアクセスできます。
MigrateAnonymous イベントを使用すると、アプリケーションを匿名で使用しているユーザーがログインしたときに、プロファイル プロパティの値を匿名プロファイルから認証済みプロファイルにコピーできます。
ユーザー プロファイルが有効になっているアプリケーションを起動すると、ASP.NET は、ProfileCommon クラスから継承するProfileBase型の新しいクラスを作成します。
ProfileCommon クラスが生成されると、Web.config ファイルで指定されたプロファイル プロパティに基づいて、ユーザー名に基づいてGetProfile オブジェクトを取得できるProfileCommon メソッドが追加されます。 現在のプロファイルの GetProfile メソッドを使用して、匿名プロファイルのプロパティ値を取得できます。 匿名プロパティの値は、認証されたユーザーの現在のプロファイルにコピーできます。
拡張メソッド
| 名前 | 説明 |
|---|---|
| GetMethodInfo(Delegate) |
指定したデリゲートによって表されるメソッドを表すオブジェクトを取得します。 |