HubConnection.Headers ...客户端缺少 SignalR

HubConnection.Headers ... Missing SignalR in Client side

我需要向 HubConnection 添加令牌 headers,如下所示:

https://docs.microsoft.com/en-us/aspnet/signalr/overview/security/hub-authorization

但是C#智能感知没有Headers属性。我使用 Blazor webassembly .Net core 3.0。 如何在客户端添加Headers到实例HubConnection?

这解决了我的问题:

connection = new HubConnectionBuilder()
                .WithUrl("http://.../MyHub", 
                    (HttpConnectionOptions options) => options.Headers.Add("Bearer", token))
                .WithAutomaticReconnect() // closed after four attempts
                .Build();