Muokkaa

Jaa


ISessionIDManager.Validate(String) Method

Definition

Confirms that the supplied session identifier is valid.

public:
 bool Validate(System::String ^ id);
public bool Validate (string id);
abstract member Validate : string -> bool
Public Function Validate (id As String) As Boolean

Parameters

id
String

The session identifier to validate.

Returns

true if the session identifier is valid; otherwise, false.

Examples

The following code example implements the Validate method and ensures the session-identifier value is a valid Guid.

public bool Validate(string id)
{
  try
  {
    Guid testGuid = new Guid(id);

    if (id == testGuid.ToString())
      return true;
  }
  catch
  {
  }

  return false;
}
Public Function Validate(id As String) As Boolean _
  Implements ISessionIDManager.Validate

  Try
    Dim testGuid As Guid = New Guid(id)

    If id = testGuid.ToString() Then _
      Return True
  Catch
  
  End Try

  Return False
End Function

Remarks

The Validate method verifies that the supplied id is a valid session identifier.

Your ISessionIDManager implementation should call the Validate method from the GetSessionID method when retrieving a session identifier from an HTTP request to ensure that the supplied session identifier is properly formatted.

Applies to

See also