System.Web.SessionState.ISessionIDManager.GetSessionID Method

Gets the session identifier from the context of the current HTTP request.

Syntax

public string GetSessionID (System.Web.HttpContext context)

Parameters

context
The current System.Web.HttpContext object that references server objects used to process HTTP requests (for example, the System.Web.HttpContext.Request and System.Web.HttpContext.Response properties).

Returns

The current session identifier sent with the HTTP request.

Remarks

The ISessionIDManager.GetSessionID(System.Web.HttpContext) method is called by the System.Web.SessionState.SessionStateModule during the System.Web.HttpApplication.AcquireRequestState and System.Web.HttpApplication.EndRequest events. If you cannot retrieve a valid session identifier from the HTTP request, return null. If the System.Web.SessionState.SessionStateModule receives null from the ISessionIDManager.GetSessionID(System.Web.HttpContext) method, it will call the ISessionIDManager.CreateSessionID(System.Web.HttpContext) method to get a new session identifier for a new session.

If it is possible that the value returned by your ISessionIDManager.CreateSessionID(System.Web.HttpContext) implementation contains characters that are not valid in an HTTP response or request, you should use the erload:System.Web.HttpUtility.UrlEncode method to encode the session-identifier value in your ISessionIDManager.SaveSessionID(System.Web.HttpContext, string, Boolean@, Boolean@) method implementation and the erload:System.Web.HttpUtility.UrlDecode method to decode the session-identifier value in your ISessionIDManager.GetSessionID(System.Web.HttpContext) method implementation.

Requirements

Namespace: System.Web.SessionState
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0