ProfileModule クラス
アセンブリ: System.Web (system.web.dll 内)
構文
解説
ユーザー プロファイルが有効にされている場合、ASP.NET は ProfileModule を使用してユーザー プロファイルを作成し、これを現在の HttpContext の Profile プロパティ内に格納します。
ProfileModule は、アプリケーションで処理することにより認証を構成できる次のイベントを公開します。
-
匿名ユーザーがログインした場合にプロファイル設定を匿名プロファイルから認証済みプロファイルへ移行するための MigrateAnonymous イベント。
-
ユーザー プロファイルの作成方法をカスタマイズするための Personalize イベント。
-
AutomaticSaveEnabled プロパティが true に設定された場合にユーザー プロファイルの保存方法を制御するための ProfileAutoSaving イベント。
ユーザー プロファイルの有効化の詳細については、「profile 要素 (ASP.NET 設定スキーマ)」を参照してください。
匿名ユーザーをサポートする匿名の識別およびプロファイル プロパティを有効にする 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 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() End Sub
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(); }
System.Web.Profile.ProfileModule
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- ProfileModule クラスのページへのリンク