The great finale
Now, the final piece of the puzzle. SignalR uses the underlying credential information found on threads in .NET. This means we will have to populate this information based on the cookie generated by our security handler. For this, we're going to need Global Application Class. Right-click on the web project and navigate to Add | New item. Select Web and then select Generic Handler. Give it the name Global.asax
:
- If the request coming in is authenticated, we want to get the cookie and decrypt it. From this, we want to put the identity into the
HttpContext
. Open theGlobal.asax.cs
file and make theApplication_AuthenticateRequest
method look like follows:protected void Application_AuthenticateRequest(object sender, EventArgs e) { if( HttpContext.Current.User != null ) { if( Request.IsAuthenticated == true ) { var ticket = FormsAuthentication.Decrypt( Context.Request.Cookies[FormsAuthentication.FormsCookieName].Value);...