This is simple example to show how to use SignalR with ASP .NET Core 3.1 and Angular 9
Server actually implement only 1 endpoint: GET -> https://localhost:5001/api/Signal. Calling this endpoint will trigger SignalR and it strat sending random messages for 1 minute
Angular 9 client just subscribe to server SignalR and then send GET request to server to trigger SignalR. Nothing fancy - all results will be output to screen with simple <li>
tag
Code contains a lot more comments to explain the mechanics
- Server side was written in .NET Core 3.1 in Visual Studio 2019
- Client side was written in Angular 9 in VS Code
Please download/install if needed
- Clone the repo:
git clone https://github.com/jasper22/signalr_example.git
- Enter
signalr_example
folder - Restore all dotnet packages:
dotnet restore
- Enter to server folder:
cd .\src\WebServer
- Start server side:
dotnet run
- Enter to client folder:
cd .\src\AngularClient\
- Restore NPM packages:
npm install
- Start the Angular client:
ng server
It should automativally redirect to main site: http://localhost:4200/ Once you enter this site the messages from server side SignalR should appear on the screen
Enjoy 😉
- Add Docker support