If I am not mistaken, you are trying to extract the user information of the registered user from the context. If this is correct, this can simply be achieved by following these steps:
- Add the [Authorize] attribute for your hub class.
- Then use Context.User.Identity to get the user id.
Since you are using a persistent connection, the authorization process should be considered by you. Refer to this link and you can customize the code provided there to suit your needs.
To change the request identifier, you must add FormsAuthentication_OnAuthenticate to your global.asax. Here is an example of the code I wrote for my application:
protected void FormsAuthentication_OnAuthenticate(Object sender, FormsAuthenticationEventArgs e) { if (FormsAuthentication.CookiesSupported == true) { if (Request.Cookies[FormsAuthentication.FormsCookieName] != null) { try { string username = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name;
Hope this helps.
source share