Building a live communication service using SignalR
The SignalR server library is included in ASP.NET Core, but the JavaScript client library is not automatically included in the project. Remember, SignalR supports multiple client types, and a web page using JavaScript is just one of them.
We will use the Library Manager CLI to get the client library from unpkg, a content delivery network (CDN) that can deliver anything found in the Node.js package manager.
Let’s add a SignalR server-side hub and client-side JavaScript to an ASP.NET Core MVC project to implement a chat feature that allows visitors to send messages to:
- Everyone currently using the website.
- Dynamically defined groups.
- A single specified user.
Good Practice: In a production solution, it would be better to host the SignalR hub in a separate web project so that it can be hosted and scaled independently from the rest of the website. Live communication can often put excessive...