2

Microsoft show us how to connect to SignalR with the following code

        connection = new HubConnectionBuilder()
            .WithUrl("http://localhost:53353/ChatHub")
            .Build();

but when you connect like this the Context.User.Identity.Name is null. Is there a way to pass user infomation through that HubConnectionBuilder method ?

  • Where are you getting `null` value for `Context.User.Identity.Name`? Do you use authentication? Please provide more information about your problem. – Stefan Jovanchevski Jun 14 '19 at 08:44
  • I get the "null" value inside the hub, and no I don't want to use authentication or anything about Identity Core right now, I just want to pass more information through that connection. – Trần Minh Thạch Jun 14 '19 at 18:54
  • As I know the `Context.User.Identity` is filled with the details for the current authenticated user. Why you want to pass more information and to get through `Context.User.Identity.Name`? What are you trying to do? Please edit your question and add more information about what you want to do and also why you want to do that. And it will be helpful if you also provide some code to see what you have done and where are you stuck. – Stefan Jovanchevski Jun 14 '19 at 19:13
  • So sorry for the late reply, the reason why I want to pass the information through this connection is because my client are apps not browser, and the backend serve as the API. So the connection for authentication and the connection for SignalR hub are difference. – Trần Minh Thạch Jul 26 '19 at 18:48

0 Answers0