SessionStateUtility.RemoveHttpSessionStateFromContext メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > SessionStateUtility.RemoveHttpSessionStateFromContext メソッドの意味・解説 

SessionStateUtility.RemoveHttpSessionStateFromContext メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

指定されコンテキストからセッション データ削除します

名前空間: System.Web.SessionState
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Shared Sub RemoveHttpSessionStateFromContext
 ( _
    context As HttpContext _
)
Dim context As HttpContext

SessionStateUtility.RemoveHttpSessionStateFromContext(context)
public static void RemoveHttpSessionStateFromContext
 (
    HttpContext context
)
public:
static void RemoveHttpSessionStateFromContext
 (
    HttpContext^ context
)
public static void RemoveHttpSessionStateFromContext
 (
    HttpContext context
)
public static function RemoveHttpSessionStateFromContext
 (
    context : HttpContext
)

パラメータ

context

セッション データ削除する HttpContext。

解説解説

RemoveHttpSessionStateFromContext メソッド指定されHttpContext からセッション データクリアます。セッション状態モジュールは、ReleaseRequestState イベントハンドラRemoveHttpSessionStateFromContext メソッド呼び出します。

使用例使用例

カスタムセッション状態モジュールReleaseRequestState イベントハンドラコード例次に示します。このイベント ハンドラは、現在の HttpContext からセッション データ削除します。このコード例は、SessionStateUtility クラストピック取り上げているコード例一部分です。

'
' Event handler for HttpApplication.ReleaseRequestState
'

Private Sub OnReleaseRequestState(source As
 Object, args As EventArgs)
  Dim app     As HttpApplication = CType(source,
 HttpApplication)
  Dim context As HttpContext     = app.Context

  ' Read the session state from the context
  Dim stateProvider As HttpSessionStateContainer
 =  _
    CType(SessionStateUtility.GetHttpSessionStateFromContext(context), HttpSessionStateContainer)

  ' If Session.Abandon() was called, remove the session data from the
 local Hashtable
  ' and execute the Session_OnEnd event from the Global.asax file.

  If stateProvider.IsAbandoned Then      
    Try
      pHashtableLock.AcquireWriterLock(Int32.MaxValue)
      pSessionItems.Remove(pSessionID)
    Finally
      pHashtableLock.ReleaseWriterLock()
    End Try

    SessionStateUtility.RaiseSessionEnd(stateProvider, Me, EventArgs.Empty)
  End If

  SessionStateUtility.RemoveHttpSessionStateFromContext(context)
End Sub
//
// Event handler for HttpApplication.ReleaseRequestState
//

private void OnReleaseRequestState(object source,
 EventArgs args)
{
  HttpApplication app     = (HttpApplication)source;
  HttpContext     context = app.Context;

  // Read the session state from the context
  HttpSessionStateContainer stateProvider = 
    (HttpSessionStateContainer)(SessionStateUtility.GetHttpSessionStateFromContext(context));

  // If Session.Abandon() was called, remove the session data from the
 local Hashtable
  // and execute the Session_OnEnd event from the Global.asax file.

  if (stateProvider.IsAbandoned)
  {
    try
    {
      pHashtableLock.AcquireWriterLock(Int32.MaxValue);
      pSessionItems.Remove(pSessionID);
    }
    finally
    {
      pHashtableLock.ReleaseWriterLock();
    }

    SessionStateUtility.RaiseSessionEnd(stateProvider, this, EventArgs.Empty);
  }

  SessionStateUtility.RemoveHttpSessionStateFromContext(context);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SessionStateUtility クラス
SessionStateUtility メンバ
System.Web.SessionState 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「SessionStateUtility.RemoveHttpSessionStateFromContext メソッド」の関連用語

SessionStateUtility.RemoveHttpSessionStateFromContext メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



SessionStateUtility.RemoveHttpSessionStateFromContext メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS