No access to the Session information through SignalR Hub. Is my design is wrong?

前端 未结 4 1160
南方客
南方客 2020-11-29 07:21

I\'ve just discovered you can\'t access the current session within the SignalR Hub.

Simplified my scenario: I\'ve tried to write a chat.

The name of the curr

4条回答
  •  长情又很酷
    2020-11-29 08:12

    One the best approach is to use Cookie instead of session. because as mentioned above , You can not use session . so When user login to your system, put its unique identifier(such as username) in cookie . then work with cookie where ever you want access session . such below...

      public class CustomUserIdProvider : IUserIdProvider
        {
            public string GetUserId(IRequest request)
            {
               return request.Cookies["ODPUserID"].Value;
            }
        }
    

提交回复
热议问题