I have a code which changes the UserId as it is written all over.
I've implemented the IUserIdProvider:
public class CustomUserIdProvider : IUserIdProvider
{
public string GetUserId(IRequest request)
{
string userId = "userName";
return userId;
}
}
And added this provider to the startup class (Configuration function):
var idProvider = new CustomUserIdProvider();
GlobalHost.DependencyResolver.Register(typeof(IUserIdProvider), () => idProvider);
I expect that all User Ids in all the hub will be "userName". I know (or maybe not?) that in order to obtain the UserId in one of the Hub functions, I need to get the value of:
Context.User.Identity.Name
But in fact, this value doesn't contain "userName", but different values:
- Empty when it's anonymous authentication
- The Windows user name in case of Windows Authentication.
In the Hub, when I look at Clients.User("userName"), I see that it's the real connection Id, so something happened (and the debugger stops at the implemented GetUserId function), but still, In the production code I won't know anything about the Custom User Id, and I want to fetch it somehow...
More Info: VS2012, IIS Express.