HttpSessionStateContainer クラス
アセンブリ: System.Web (system.web.dll 内)


ASP.NET は、複数の要求に対して一意のブラウザ セッションに関連付けられた情報を格納するためのセッション状態管理機能を提供します。キー名または数値インデックスによって参照する一連の値を格納できます。セッション値には、現在の HttpContext の Session プロパティまたは Page の Session プロパティを使用してアクセス可能な HttpSessionState クラスを使用してアクセスします。HttpSessionState クラスは、セッション状態コンテナを参照してセッション状態値とセッション レベルの設定にアクセスします。このコンテナは、HttpApplication のセッション状態モジュールによってセッション状態データを入力してから現在の要求の HttpContext に追加された IHttpSessionState インターフェイスの実装です。
HttpSessionState クラスは、セッションの設定および値をメモリで管理する HttpSessionStateContainer クラスを呼び出します。
HttpSessionStateContainer クラスは、IHttpSessionState インターフェイスの ASP.NET 実装です。HttpSessionStateContainer クラスは、アプリケーション コードから呼び出すためのものではありません。SessionStateModule をカスタムのセッション状態モジュールで置き換える場合は、HttpSessionStateContainer クラスを使用するか、または独自の IHttpSessionState インターフェイスの実装を提供します。

HttpSessionStateContainer クラスを現在の要求のセッション状態コンテナとして使用するカスタムのセッション状態モジュールの例については、SessionStateUtility クラスの概要を参照してください。


System.Web.SessionState.HttpSessionStateContainer


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


HttpSessionStateContainer コンストラクタ
アセンブリ: System.Web (system.web.dll 内)

Public Sub New ( _ id As String, _ sessionItems As ISessionStateItemCollection, _ staticObjects As HttpStaticObjectsCollection, _ timeout As Integer, _ newSession As Boolean, _ cookieMode As HttpCookieMode, _ mode As SessionStateMode, _ isReadonly As Boolean _ )
Dim id As String Dim sessionItems As ISessionStateItemCollection Dim staticObjects As HttpStaticObjectsCollection Dim timeout As Integer Dim newSession As Boolean Dim cookieMode As HttpCookieMode Dim mode As SessionStateMode Dim isReadonly As Boolean Dim instance As New HttpSessionStateContainer(id, sessionItems, staticObjects, timeout, newSession, cookieMode, mode, isReadonly)
public HttpSessionStateContainer ( string id, ISessionStateItemCollection sessionItems, HttpStaticObjectsCollection staticObjects, int timeout, bool newSession, HttpCookieMode cookieMode, SessionStateMode mode, bool isReadonly )
public: HttpSessionStateContainer ( String^ id, ISessionStateItemCollection^ sessionItems, HttpStaticObjectsCollection^ staticObjects, int timeout, bool newSession, HttpCookieMode cookieMode, SessionStateMode mode, bool isReadonly )
public HttpSessionStateContainer ( String id, ISessionStateItemCollection sessionItems, HttpStaticObjectsCollection staticObjects, int timeout, boolean newSession, HttpCookieMode cookieMode, SessionStateMode mode, boolean isReadonly )
public function HttpSessionStateContainer ( id : String, sessionItems : ISessionStateItemCollection, staticObjects : HttpStaticObjectsCollection, timeout : int, newSession : boolean, cookieMode : HttpCookieMode, mode : SessionStateMode, isReadonly : boolean )


カスタムのセッション状態モジュールの AcquireRequestState イベント ハンドラのコード例を次に示します。このイベント ハンドラは、HttpSessionStateContainer オブジェクトに新規または既存のセッション情報を入力し、AddHttpSessionStateToContext メソッドを使用して現在の要求の HttpContext に追加します。カスタムのセッション状態モジュールの完全なコード例については、SessionStateUtility クラスの概要を参照してください。
' ' Event handler for HttpApplication.AcquireRequestState ' Private Sub OnAcquireRequestState(source As Object, args As EventArgs) Dim app As HttpApplication = CType(source, HttpApplication) Dim context As HttpContext = app.Context Dim isNew As Boolean = False pSessionData = Nothing pSessionID = pSessionIDManager.GetSessionID(context) If Not pSessionID Is Nothing Then Try pHashtableLock.AcquireReaderLock(Int32.MaxValue) pSessionData = CType(pSessionItems(pSessionID), SessionItem) If Not pSessionData Is Nothing Then _ pSessionData.Expires = DateTime.Now.AddMinutes(pTimeout) Finally pHashtableLock.ReleaseReaderLock() End Try Else Dim redirected, cookieAdded As Boolean pSessionID = pSessionIDManager.CreateSessionID(context) pSessionIDManager.SaveSessionID(context, pSessionID, redirected, cookieAdded) If redirected Then Return End If If pSessionData Is Nothing Then ' Identify the session as a New session state instance. Create a New SessionItem ' and add it to the local Hashtable. isNew = True pSessionData = New SessionItem() pSessionData.Items = New SessionStateItemCollection() pSessionData.StaticObjects = SessionStateUtility.GetSessionStaticObjects(context) pSessionData.Expires = DateTime.Now.AddMinutes(pTimeout) Try pHashtableLock.AcquireWriterLock(Int32.MaxValue) pSessionItems(pSessionID) = pSessionData Finally pHashtableLock.ReleaseWriterLock() End Try End If ' Add the session data to the current HttpContext. SessionStateUtility.AddHttpSessionStateToContext(context, _ New HttpSessionStateContainer(pSessionID, _ pSessionData.Items, _ pSessionData.StaticObjects, _ pTimeout, _ isNew, _ pCookieMode, _ SessionStateMode.Custom, _ False)) ' Execute the Session_OnStart event for a New session. If isNew Then RaiseEvent Start(Me, EventArgs.Empty) End Sub ' ' Event for Session_OnStart event in the Global.asax file. ' Public Event Start As EventHandler
// // Event handler for HttpApplication.AcquireRequestState // private void OnAcquireRequestState(object source, EventArgs args) { HttpApplication app = (HttpApplication)source; HttpContext context = app.Context; bool isNew = false; pSessionData = null; pSessionID = pSessionIDManager.GetSessionID(context); if (pSessionID != null) { try { pHashtableLock.AcquireReaderLock(Int32.MaxValue); pSessionData = (SessionItem)pSessionItems[pSessionID]; if (pSessionData != null) pSessionData.Expires = DateTime.Now.AddMinutes(pTimeout); } finally { pHashtableLock.ReleaseReaderLock(); } } else { bool redirected, cookieAdded; pSessionID = pSessionIDManager.CreateSessionID(context); pSessionIDManager.SaveSessionID(context, pSessionID, out redirected, out cookieAdded); if (redirected) return; } if (pSessionData == null) { // Identify the session as a new session state instance. Create a new SessionItem // and add it to the local Hashtable. isNew = true; pSessionData = new SessionItem(); pSessionData.Items = new SessionStateItemCollection(); pSessionData.StaticObjects = SessionStateUtility.GetSessionStaticObjects(context); pSessionData.Expires = DateTime.Now.AddMinutes(pTimeout); try { pHashtableLock.AcquireWriterLock(Int32.MaxValue); pSessionItems[pSessionID] = pSessionData; } finally { pHashtableLock.ReleaseWriterLock(); } } // Add the session data to the current HttpContext. SessionStateUtility.AddHttpSessionStateToContext(context, new HttpSessionStateContainer(pSessionID, pSessionData.Items, pSessionData.StaticObjects, pTimeout, isNew, pCookieMode, SessionStateMode.Custom, false)); // Execute the Session_OnStart event for a new session. if (isNew && Start != null) { Start(this, EventArgs.Empty); } } // // Event for Session_OnStart event in the Global.asax file. // public event EventHandler Start;

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


HttpSessionStateContainer プロパティ

名前 | 説明 | |
---|---|---|
![]() | CodePage | 現在のセッションの文字セット識別子を取得または設定します。 |
![]() | CookieMode | アプリケーションが Cookie なしのセッション用に構成されているかどうかを示す値を取得します。 |
![]() | Count | セッション状態コレクション内の項目の数を取得します。 |
![]() | IsAbandoned | 現在のセッションが破棄されているかどうかを示す値を取得します。 |
![]() | IsCookieless | セッション ID を URL に埋め込むか、HTTP cookie に格納するかを示す値を取得します。 |
![]() | IsNewSession | 現在の要求でセッションが作成されたかどうかを示す値を取得します。 |
![]() | IsReadOnly | セッションが読み取り専用かどうかを示す値を取得します。 |
![]() | IsSynchronized | セッション状態値のコレクションへのアクセスが同期されている (スレッド セーフである) かどうかを示す値を取得します。 |
![]() | Item | オーバーロードされます。 個別のセッション値を取得または設定します。 |
![]() | Keys | セッション状態のコレクションに格納されているすべての値のキーのコレクションを取得します。 |
![]() | LCID | 現在のセッションのロケール識別子 (LCID: locale identifier) を取得または設定します。 |
![]() | Mode | 現在のセッション状態モードを取得します。 |
![]() | SessionID | セッションの一意の識別子を取得します。 |
![]() | StaticObjects | ASP.NET アプリケーションの Global.asax ファイルの <object Runat="Server" Scope="Session"/> タグで宣言されているオブジェクトのコレクションを取得します。 |
![]() | SyncRoot | セッション状態値のコレクションへのアクセスの同期に使用できるオブジェクトを取得します。 |
![]() | Timeout | セッション状態プロバイダがセッションを終了するまでに、要求間で許容される時間 (分単位) を取得または設定します。 |

HttpSessionStateContainer メソッド

名前 | 説明 | |
---|---|---|
![]() | Abandon | 現在のセッションに破棄のマークを付けます。 |
![]() | Add | 新しい項目をセッション状態に追加します。 |
![]() | Clear | セッション状態のコレクションからすべての値とキーを削除します。 |
![]() | CopyTo | セッション状態値のコレクションを 1 次元配列にコピーします。コピー操作は、指定した配列内のインデックスから始まります。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetEnumerator | 現在のセッションのすべてのセッション状態変数名を読み出すために使用する列挙子を返します。 |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | Remove | セッション状態のコレクションから項目を削除します。 |
![]() | RemoveAll | すべてのセッション状態値を削除します。 |
![]() | RemoveAt | セッション状態のコレクションの指定したインデックス位置にある項目を削除します。 |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

HttpSessionStateContainer メンバ
現在の要求のセッション レベルの設定とセッション状態値を格納します。
HttpSessionStateContainer データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | CodePage | 現在のセッションの文字セット識別子を取得または設定します。 |
![]() | CookieMode | アプリケーションが Cookie なしのセッション用に構成されているかどうかを示す値を取得します。 |
![]() | Count | セッション状態コレクション内の項目の数を取得します。 |
![]() | IsAbandoned | 現在のセッションが破棄されているかどうかを示す値を取得します。 |
![]() | IsCookieless | セッション ID を URL に埋め込むか、HTTP cookie に格納するかを示す値を取得します。 |
![]() | IsNewSession | 現在の要求でセッションが作成されたかどうかを示す値を取得します。 |
![]() | IsReadOnly | セッションが読み取り専用かどうかを示す値を取得します。 |
![]() | IsSynchronized | セッション状態値のコレクションへのアクセスが同期されている (スレッド セーフである) かどうかを示す値を取得します。 |
![]() | Item | オーバーロードされます。 個別のセッション値を取得または設定します。 |
![]() | Keys | セッション状態のコレクションに格納されているすべての値のキーのコレクションを取得します。 |
![]() | LCID | 現在のセッションのロケール識別子 (LCID: locale identifier) を取得または設定します。 |
![]() | Mode | 現在のセッション状態モードを取得します。 |
![]() | SessionID | セッションの一意の識別子を取得します。 |
![]() | StaticObjects | ASP.NET アプリケーションの Global.asax ファイルの <object Runat="Server" Scope="Session"/> タグで宣言されているオブジェクトのコレクションを取得します。 |
![]() | SyncRoot | セッション状態値のコレクションへのアクセスの同期に使用できるオブジェクトを取得します。 |
![]() | Timeout | セッション状態プロバイダがセッションを終了するまでに、要求間で許容される時間 (分単位) を取得または設定します。 |

名前 | 説明 | |
---|---|---|
![]() | Abandon | 現在のセッションに破棄のマークを付けます。 |
![]() | Add | 新しい項目をセッション状態に追加します。 |
![]() | Clear | セッション状態のコレクションからすべての値とキーを削除します。 |
![]() | CopyTo | セッション状態値のコレクションを 1 次元配列にコピーします。コピー操作は、指定した配列内のインデックスから始まります。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetEnumerator | 現在のセッションのすべてのセッション状態変数名を読み出すために使用する列挙子を返します。 |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | Remove | セッション状態のコレクションから項目を削除します。 |
![]() | RemoveAll | すべてのセッション状態値を削除します。 |
![]() | RemoveAt | セッション状態のコレクションの指定したインデックス位置にある項目を削除します。 |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

Weblioに収録されているすべての辞書からHttpSessionStateContainerを検索する場合は、下記のリンクをクリックしてください。

- HttpSessionStateContainerのページへのリンク