SignalR – Checking if a user is still connected

Probably the most used solution is to keep a static variable containing users currently connected and overriding OnConnect and OnDisconnect or implementing IDisconnect depending on the version that you use. You would implement something like this: public class MyHub : Hub { private static List<string> users = new List<string>(); public override Task OnConnected() { users.Add(Context.ConnectionId); … Read more

Context.User.Identity.Name is null with SignalR 2.X.X. How to fix it?

I found the final solution, this is the code of my OWIN startup class: public void Configuration(IAppBuilder app) { app.MapSignalR(); // Enable the application to use a cookie to store information for the signed i user app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString(“/Home/Index”) }); // Use a cookie to temporarily store information … Read more