JwtSecurityTokenHandler.CanReadToken Method (String)
Determines if the string is a well formed JSON Web Token (JWT).
Namespace: System.IdentityModel.Tokens
Assembly: System.IdentityModel.Tokens.Jwt (in System.IdentityModel.Tokens.Jwt.dll)
Syntax
'Declaration
Public Overridable Function CanReadToken ( _
token As String _
) As Boolean
public virtual bool CanReadToken(
string token
)
public:
virtual bool CanReadToken(
String^ token
)
abstract CanReadToken :
token:string -> bool
override CanReadToken :
token:string -> bool
public function CanReadToken(
token : String
) : boolean
Parameters
token
Type: System.StringA string that represents a token.
Return Value
Type: System.Boolean
Returns true if the token is in JSON Compact serialization format, false if token.Length * 2 is greater than MaxTokenSizeInBytes.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | token is null. |
Remarks
Uses IsMatch with the following expression:( token, @"^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$" ).
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.