'How Can the `id` Query String Parameter in a Blazor WebSocket Connection Be Accessed?

When debugging with my Blazor server-side application, I see the following message:

[2022-02-25T10:40:19.177Z] Information: WebSocket connected to wss://<host>/_blazor?id=<_identifier_>.

I am interested in the id query string parameter specifically. Is this value available in any way within a Blazor application? I looked in the ComponentHub.Context.ConnectionId but it does not appear to match this value.

I do realize that I can use the IHttpContextAccesssor, but want to stay away from this as this is considered poor practice with Blazor applications.

(If I am mistaken about this particular scenario that would be great to know as well.)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source