Blazor Server APP

Selvaraj, Deepak 0 Reputation points
2025-06-26T21:08:52.5+00:00

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.

Developer technologies .NET Blazor
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2025-06-27T16:17:11.03+00:00

    The messages packets themselves are in a binary format, not JSON, so you can not switch the hub. If converted to JSON, it would just be a base64 string.also, as it’s a persistent websocket connection, there is no middleware. Just the signalr server and client.

    note: The request that created the server hub and created the blazor server instance has completed before channel has opened.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.