Introduction
Real-time applications are apps that update instantly without needing to refresh the page. Examples include chat apps, live dashboards, notifications, and online games.
With ASP.NET Core and SignalR, we can push updates from the server to clients in real-time. Angular helps us create a responsive frontend to display this data instantly.
In this tutorial, we will build a simple real-time chat application using ASP.NET Core and Angular.
Architecture Diagram
Here’s a high-level workflow of our real-time app:
+----------------+ WebSocket / SignalR +----------------+
| Angular App | <----------------------------------> | ASP.NET Core |
| (Frontend) | | Server |
+----------------+ +----------------+
^ |
| |
+------------------ Database (SQL Server) ------------+
Explanation:
Angular connects to ASP.NET Core via SignalR Hub.
Messages from one client are sent to the server.
Server pushes the message to all connected clients instantly.
Optionally, messages are stored in a SQL Server database for persistence.
Step 1. Create ASP.NET Core Backend
Create a new ASP.NET Core Web API project:
dotnet new webapi -n RealTimeChatApp
cd RealTimeChatApp
Add SignalR NuGet package:
dotnet add package Microsoft.AspNetCore.SignalR
Create a Hub Class:
using Microsoft.AspNetCore.SignalR;
namespace RealTimeChatApp.Hubs
{
public class ChatHub : Hub
{
public async Task SendMessage(string user, string message)
{
await Clients.All.SendAsync("ReceiveMessage", user, message);
}
}
}
Configure SignalR in
Program.cs:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddSignalR();
var app = builder.Build();
app.MapControllers();
app.MapHub<ChatHub>("/chathub");
app.Run();
Step 2. Create Angular Frontend
Create a new Angular project:

Join the conversation! Your thoughts help the community grow.