ISessionIDManager.Validate(String) 方法
定义
确认提供的会话标识符有效。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
参数
- id
- String
要验证的会话标识符。The session identifier to validate.
返回
如果会话标识符有效,则为 true;否则为 false。true if the session identifier is valid; otherwise, false.
示例
下面的代码示例实现 Validate 方法,并确保会话标识符值是有效的 Guid 。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
注解
Validate方法验证所提供的 id 是否为有效的会话标识符。The Validate method verifies that the supplied id is a valid session identifier.
ISessionIDManager Validate GetSessionID 从 HTTP 请求检索会话标识符时,实现应从方法调用方法,以确保所提供的会话标识符的格式正确。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.