I’m building a Blazor Server application, which uses WebSockets for real-time communication (via SignalR).
By default, Blazor uses MessagePack as the serialization protocol, which results in a binary transfer format. For debugging and interoperability purposes, I’d prefer to use JSON (text format) instead.
Since Blazor Server abstracts away the SignalR connection details (e.g., via MapBlazorHub()
), I can’t see how to configure it to use JsonHubProtocol
instead of the default.
Question: Is there a supported way in Blazor Server to switch the default SignalR protocol from MessagePack to JSON, so that messages are transferred in text format instead of binary?
I am using .NET 8.0
and builder.Services.AddServerSideBlazor();
.
Any guidance on configuring the protocol or middleware at startup would be appreciated.