SignalR send custom class

Viewed 50

I would like to use a custom class on SignalR. But an client side I just get 'null' in the class.

Why am I getting such exceptions? Exception thrown: 'System.Text.Json.JsonException' in System.Text.Json.dll Exception thrown: 'System.IO.InvalidDataException' in Microsoft.AspNetCore.SignalR.Protocols.Json.dll

3 Answers

It's likely your custom class isn't properly serializable as JSON.

I found the problem. Need to use JsonConvert.SerializeObject and JsonConvert.DeserializeObject.

Try making sure that the members are "public properties" on the instance to make it all smooth. (or Records). (would be a comment if I had better rep)

Related