Identity icon indicating copy to clipboard operation
Identity copied to clipboard

ClaimsPrincipal.WriteTo(BinaryWriter) -> new ClaimsPrincipal(BinaryReader) not working

Open nemenos opened this issue 9 years ago • 2 comments

serialized.zip

Hello, I'm using dotnetcore 1.1 with full framework 4.6.2. I'm trying to implement an ITicketStore. using ClaimsPrincipal.WriteTo(BinaryWriter) and reading it back with new ClaimsPrincipal(BinaryReader) :

        var memoryStream = new MemoryStream();
        var binaryWriter = new BinaryWriter(memoryStream);
        ticket.Principal.WriteTo(binaryWriter);

        memoryStream.Seek(0, SeekOrigin.Begin);
        BinaryReader reader = new BinaryReader(memoryStream);
        var claimsPrincipal = new ClaimsPrincipal(reader);

throws ArgumentException: an item with the same key has already been added

Thanks in advance, Andrea

PS. I attached File generated by serializing to file instead of to memorystream, same error

nemenos avatar Dec 21 '16 11:12 nemenos

Anyway, looking into source code, I solved using TicketSerializer.Default

nemenos avatar Dec 21 '16 14:12 nemenos

Still having the same problem on netstandard 2.0

filoe avatar Apr 01 '18 11:04 filoe