ProfileModule.ProfileAutoSaving イベント

定義

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

public:
 event System::Web::Profile::ProfileAutoSaveEventHandler ^ ProfileAutoSaving;
public event System.Web.Profile.ProfileAutoSaveEventHandler ProfileAutoSaving;
member this.ProfileAutoSaving : System.Web.Profile.ProfileAutoSaveEventHandler 
Public Custom Event ProfileAutoSaving As ProfileAutoSaveEventHandler 

イベントの種類

次のコード例は、 ProfileAutoSaving ASP.NET アプリケーションの Global.asax ファイルに含まれるイベントを示しています。

public void Profile_ProfileAutoSaving(object sender, ProfileAutoSaveEventArgs args)
{
  if (Profile.Cart.HasChanged)
    args.ContinueWithProfileAutoSave = true;
  else
    args.ContinueWithProfileAutoSave = false;
}
Public Sub Profile_ProfileAutoSaving(sender As Object, args As ProfileAutoSaveEventArgs)
  If Profile.Cart.HasChanged Then
    args.ContinueWithProfileAutoSave = True
  Else
    args.ContinueWithProfileAutoSave = False
  End If
End Sub

注釈

プロパティtrueが の場合、イベントはProfileAutoSavingページの実行の最後にProfileManager.AutomaticSaveEnabled発生します。 このトピックの例に示すように、グローバル イベントをProfileModule使用してProfile_ProfileAutoSaving、ASP.NET アプリケーションの Global.asax ファイル内の クラスのイベントにアクセスProfileAutoSavingできます。

メソッドはSettingsBase.Save、プリミティブ型、IsDirty文字列、またはDateTimeオブジェクトで構成されるプロパティが変更されているかどうかを判断するために、ユーザー プロファイル内のそれぞれのSettingsPropertyValueプロパティ値を確認します。 メソッドは Save 、カスタム クラスが変更されたかどうかを明示的に判断できません。 イベントを ProfileAutoSaving 使用すると、カスタム オブジェクトが変更されたかどうかを判断し、変更されたオブジェクトの自動保存を続行するか、オブジェクトが変更されていない場合は自動保存を取り消すことができます。

プロファイルの自動保存操作を取り消すには、 イベントで ProfileAutoSaving プロパティを ContinueWithProfileAutoSavefalse設定します。それ以外の場合は、 プロパティを ContinueWithProfileAutoSavetrue設定します。

イベントのサブスクライバーが複数存在する ProfileAutoSaving 可能性があります。 では ProfileModule 、 プロパティが設定されている最後の値が ContinueWithProfileAutoSave 使用されます。 その結果、以前のサブスクライバーによって設定 ContinueWithProfileAutoSave された値を上書きする必要がある場合があるため、自動保存を取り消す場合も続行する場合でも、イベントで ProfileAutoSaving プロパティを明示的に設定することをお勧めします。

適用対象

こちらもご覧ください