SessionStateUtility.AddHttpSessionStateToContext Method

Applies the session data to the context for the current request.

Namespace: System.Web.SessionState
Assembly: System.Web (in system.web.dll)

public:
static void AddHttpSessionStateToContext (
	HttpContext^ context, 
	IHttpSessionState^ container
)
public static void AddHttpSessionStateToContext (
	HttpContext context, 
	IHttpSessionState container
)
public static function AddHttpSessionStateToContext (
	context : HttpContext, 
	container : IHttpSessionState
)
Not applicable.

Parameters

context

The HttpContext object to which to add the HttpSessionState object.

container

The IHttpSessionState implementation instance to add to the specified HTTP context.

Exception typeCondition

HttpException

An HttpSessionState object for the current session has already been added to the specified context.

The AddHttpSessionStateToContext method is used by a session-state module to apply session data to the current request. This occurs during the AcquireRequestState event at the beginning of a request. Session data for the current request is either retrieved for an existing session or created for a new session. The session data is then encapsulated in an IHttpSessionState implementation instance, which is passed to the AddHttpSessionStateToContext method along with the current HttpContext. The supplied session data is then made available to application code through the Session property of the current context.

The following code example shows the handler for the AcquireRequestState event in a custom session-state module. The custom module retrieves existing session information or creates new session information and uses the AddHttpSessionStateToContext method to add it to the HttpContext of the current request. This code example is part of a larger example provided for the SessionStateUtility class.

No code example is currently available or this language may not be supported.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show: