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

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

See Also

Reference

JwtSecurityTokenHandler Class

CanReadToken Overload

System.IdentityModel.Tokens Namespace