Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
SignalR: Real-time Application Development - Second Edition

You're reading from   SignalR: Real-time Application Development - Second Edition A fast-paced guide to develop, test, and deliver real-time communication in your .NET applications using SignalR

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher Packt
ISBN-13 9781785285455
Length 222 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Einar Ingerbrigsten Einar Ingerbrigsten
Author Profile Icon Einar Ingerbrigsten
Einar Ingerbrigsten
Arrow right icon
View More author details
Toc

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:

The great finale
  1. 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 the Global.asax.cs file and make the Application_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);...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image