ISessionIDManager.GetSessionID Method

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

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

String^ GetSessionID (
	HttpContext^ context
)
String GetSessionID (
	HttpContext context
)
function GetSessionID (
	context : HttpContext
) : String
Not applicable.

Parameters

context

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

Return Value

The current session identifier sent with the HTTP request.

The GetSessionID method is called by the 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 a null reference (Nothing in Visual Basic). If the SessionStateModule receives a null reference (Nothing in Visual Basic) from the GetSessionID method, it will call the CreateSessionID method to get a new session identifier for a new session.

If it is possible that the value returned by your CreateSessionID implementation contains characters that are not valid in an HTTP response or request, you should use the UrlEncode method to encode the session-identifier value in your SaveSessionID method implementation and the UrlDecode method to decode the session-identifier value in your GetSessionID method implementation.

The following code example shows a partially implemented GetSessionID method. If your custom session-ID manager supports cookieless session identifiers, you will need to implement a solution for sending and retrieving session identifiers in the URL, such as an ISAPI filter.

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: