ProfileModule クラス

定義

ユーザー プロファイルとプロファイル イベントの作成を管理します。 このクラスは継承できません。

public ref class ProfileModule sealed : System::Web::IHttpModule
public sealed class ProfileModule : System.Web.IHttpModule
type ProfileModule = class
    interface IHttpModule
Public NotInheritable Class ProfileModule
Implements IHttpModule
継承
ProfileModule
実装

次の例は、匿名ユーザーをサポートする匿名 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

注釈

ユーザー プロファイルが有効になっている場合、ASP.NET は をProfileModule使用してユーザー プロファイルを作成し、現在HttpContextの の プロパティにProfile格納します。

では ProfileModule 、アプリケーションで認証を構成するために処理できる次のイベントが公開されます。

  • 匿名ユーザーが MigrateAnonymous ログインしたときに、プロファイル設定を匿名プロファイルから認証済みプロファイルに移行するイベント。

  • イベント。 Personalize ユーザー プロファイルの作成方法をカスタマイズします。

  • プロパティが ProfileAutoSaving に設定されている場合にユーザー プロファイルを保存する方法を AutomaticSaveEnabled 制御する trueイベント。

ユーザー プロファイルの有効化の詳細については、「 profile 要素 (ASP.NET 設定スキーマ)」を参照してください。

コンストラクター

ProfileModule()

ProfileModule クラスの新しいインスタンスを初期化します。

メソッド

Dispose()

ProfileModule によって使用されているすべてのリソースを解放します。

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
Init(HttpApplication)

ProfileModule オブジェクトが作成されるときに、初期化コードを呼び出します。

MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

イベント

MigrateAnonymous

あるプロファイルに対する匿名ユーザーがログインするときに発生します。

Personalize

ユーザー プロファイルが作成される前に発生します。

ProfileAutoSaving

プロファイルの自動保存が有効になっている場合、ページ実行の終了時に発生します。

適用対象

こちらもご覧ください