How to use SignalR in ASP.Net Core

SignalR for ASP.Net Core is a new version of the SignalR library that enables you to implement real-time communications in ASP.Net Core applications. Here the term “real-time” means that the server application can push data or content to connected clients as soon as updates happen, without clients having to request them. You can learn more about SignalR from my earlier post on SignalR for ASP.Net.
In this article we’ll look at how we can work with SignalR in ASP.Net Core. We’ll create a simple server that broadcasts text messages to clients, and a console application that consumes the messages.
Create an ASP.Net Core project and install SignalR
First off, create a new ASP.Net Core project in Visual Studio. Assuming that you’re running Visual Studio Community Edition 2017 and .Net Core is already installed in your system, follow these steps to create an ASP.Net Core application.
- In Visual Studio, click on File > New > Project.
- Select “ASP.Net Core Web Application (.Net Core)” from the list of the templates displayed.
- Specify a name for the project and click OK to save it.
- In the “New .Net Core Web Application…” window, select “Web API.”
- Ensure that “Enable Docker Support” is unchecked and that “No Authentication” is selected as we won’t be using either here.
- Click OK.