User283571144 posted
Hi Zacho7,
Zacho7
1. How should my custom IUserIdProvider look if the user doesn't have a "guid" cookie set? Where does this fit into the pipeline if a user comes in with no "guid" cookie
According to your description, I suggest you could return a null value string to the user.
We need firstly check the user is IsAuthenticated.
If user is IsAuthenticated, then you could return user name.
Then check the request has cookie.
If the request has cookie then return the cookie value.
If the request doesn't have the cookie return "Null Cookie User" string.
I suggest you could add the if condition in the hub's OnConnected event to check the Context.RequestCookies[""]'s value.
If the value is "Null Cookie User", then you could redirect to login page or call another page to add the cookie.
Zacho7
2. How do I reference this new "id" (guid) in my hub class? I had been previously using Context.ConnectionId
You could use Context.RequestCookies[""].value to get the current user's cookie.
If user authenticated, you could use Context.User.Identity.Name to get the current user's name.
Best Regards,
Brando