Editare

Partajați prin


ISessionIDManager.CreateSessionID(HttpContext) Method

Definition

Creates a unique session identifier.

public:
 System::String ^ CreateSessionID(System::Web::HttpContext ^ context);
public string CreateSessionID (System.Web.HttpContext context);
abstract member CreateSessionID : System.Web.HttpContext -> string
Public Function CreateSessionID (context As HttpContext) As String

Parameters

context
HttpContext

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

Returns

A unique session identifier.

Examples

The following code example implements the CreateSessionID method. The method creates a new Guid to be used as a session identifier.

public string CreateSessionID(HttpContext context)
{
  return Guid.NewGuid().ToString();
}
Public Function CreateSessionID(context As HttpContext) As String _
  Implements ISessionIDManager.CreateSessionID

  Return Guid.NewGuid().ToString()
End Function

Remarks

The CreateSessionID method is used to generate a unique session identifier that the SessionStateModule object will use to identify a new session. The value returned by CreateSessionID must be unique and must contain valid characters that can be stored in an HTTP response and request. 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.

Applies to

See also