ISessionIDManager.CreateSessionID(HttpContext) Método
Definição
Cria um identificador de sessão exclusivo.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
Parâmetros
- context
- HttpContext
O objeto HttpContext atual que faz referência a objetos de servidor usados para processar solicitações HTTP (por exemplo, as propriedades Request e Response).The current HttpContext object that references server objects used to process HTTP requests (for example, the Request and Response properties).
Retornos
Um identificador de sessão exclusivo.A unique session identifier.
Exemplos
O exemplo de código a seguir implementa o CreateSessionID método.The following code example implements the CreateSessionID method. O método cria um novo Guid para ser usado como um identificador de sessão.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
Comentários
O CreateSessionID método é usado para gerar um identificador de sessão exclusivo que o SessionStateModule objeto usará para identificar uma nova sessão.The CreateSessionID method is used to generate a unique session identifier that the SessionStateModule object will use to identify a new session. O valor retornado por CreateSessionID deve ser exclusivo e deve conter caracteres válidos que possam ser armazenados em uma resposta e solicitação HTTP.The value returned by CreateSessionID must be unique and must contain valid characters that can be stored in an HTTP response and request. Se for possível que o valor retornado pela sua CreateSessionID implementação contenha caracteres que não são válidos em uma resposta ou solicitação HTTP, você deve usar o UrlEncode método para codificar o valor de identificador de sessão em sua SaveSessionID implementação de método e o UrlDecode método para decodificar o valor de identificador de sessão em sua GetSessionID implementação de método.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.