Learn how we can add authentication to Fun Chat to show a message came from an authenticated user. See how to map users to connections.
- [Instructor] In this video we're going to be using … ASP.NET authentication with SignalR … to add usernames to our messsages, … so we know who is sending messages. … We'll start by modifying our chat hub, … our new message broadcast to send out the username … of the user who sent the message. … We'll grab our username … from Context.User.Identity.Name, … and we'll pass in the username … as the first parameter to our broadcast. … That's the hub side taken care of, … now let's just reflect that change on the client side. … We'll go to our Index.cshtml. … We'll scroll down to our onNewMessage broadcast listener, … and add our new username parameter. … We'll perpend our username to our message. … And it's worth noting that the username can be null … if someone is unauthenticated. … So we'll handle that situation … by saying anonymous. … And let's run our app and see if that works. … I've opened the app again in two different windows … to simulate two different users. … On the left side I'm logged in as a demo user, …
- What is SignalR?
- Scaling out an architecture using SignalR
- Adding a SignalR hub and client to an MVC app
- Authentication with SignalR
- How SignalR groups work
- Adding chat rooms with groups