Building Real-Time Apps with ASP.NET Core and SignalR: Chat Apps, Live Dashboards & Scalability

Building Real-Time Apps with ASP.NET Core and SignalR: Chat Apps, Live Dashboards & Scalability

By Xaylon Labs
Keywords: ASP.NET SignalR Tutorial, Real-Time ASP.NET Core, SignalR Chat App, Xaylon Labs

In 2025, users expect applications to react instantly — whether it’s chatting with teammates, watching live stock updates, tracking delivery, monitoring IoT sensors, or collaborating inside dashboards. Traditional request–response architecture simply can’t deliver that level of immediacy.

That’s where ASP.NET Core SignalR shines.

SignalR makes it incredibly easy to add real-time two-way communication to your .NET applications. No need to manually handle WebSockets, long polling, or server-sent events — SignalR abstracts everything.

This guide from Xaylon Labs walks you through:

  • What SignalR is and why it matters

  • Building a basic real-time chat app

  • Creating a live dashboard that updates continuously

  • Scaling SignalR using Redis and Azure SignalR Service

  • Handling security, authentication & connection management

  • Deployment & performance optimization steps

Let’s dive in.

1. Introduction to SignalR

What is SignalR?

SignalR is a real-time communication library for ASP.NET Core that enables:

  • Live chat

  • Real-time dashboards

  • Notifications

  • Collaborative features

  • Multiplayer games

  • IoT live tracking

How SignalR Works

SignalR automatically selects the best protocol:

  • WebSockets (preferred)

  • Server-Sent Events (fallback)

  • Long polling (fallback)

As a developer, you interact with a Hub, which is a high-level abstraction over messaging.

Why It’s Powerful (Xaylon Labs Perspective)

At Xaylon Labs, we use SignalR for enterprise-grade apps where:

  • users need instant feedback

  • dashboards must stream live data

  • collaborative tools require shared state

  • IoT devices push real-time metrics

SignalR accelerates development and stays performant even at scale.

2. Building a Simple Real-Time Chat App (SignalR Server + Client)

Let’s build the classic example — a chat app — using minimal code.

Step 1: Create a SignalR Hub

ChatHub.cs

using Microsoft.AspNetCore.SignalR;

 

public class ChatHub : Hub

{

    public async Task SendMessage(string user, string message)

    {

        await Clients.All.SendAsync(“ReceiveMessage”, user, message);

    }

}

The hub receives messages and broadcasts them to all connected clients.

Step 2: Register SignalR in Program.cs

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddSignalR();

var app = builder.Build();

app.MapHub<ChatHub>(“/chatHub”);

app.Run();

This exposes the hub at /chatHub.

Step 3: Simple HTML/JS Client

index.html

<script src=”https://cdnjs.cloudflare.com/ajax/libs/microsoft-signalr/7.0.5/signalr.min.js”></script>

 

<div>

    <input id=”user” placeholder=”Name” />

    <input id=”message” placeholder=”Type message…” />

    <button onclick=”send()”>Send</button>

</div>

 

<ul id=”messages”></ul>

 

<script>

    const connection = new signalR.HubConnectionBuilder()

        .withUrl(“/chatHub”)

        .build();

    connection.on(“ReceiveMessage”, (user, message) => {

        const li = document.createElement(“li”);

        li.textContent = `${user}: ${message}`;

        document.getElementById(“messages”).appendChild(li);

    });

   async function send() {

        const user = document.getElementById(“user”).value;

        const msg = document.getElementById(“message”).value;

        await connection.invoke(“SendMessage”, user, msg);

    }

    connection.start();

</script>

 

Now you have a real-time chat app working in minutes.

3. Live Dashboard Example (Server Push Updates)

Imagine monitoring:

  • Stock prices

  • CPU/memory usage

  • IoT sensor values

  • Ecommerce live orders

  • Logistics tracking

SignalR allows the server to push updates without client polling.

Step 1: Create MetricsHub

public class MetricsHub : Hub

{

    public async Task BroadcastMetrics(string value)

    {

        await Clients.All.SendAsync(“ReceiveMetrics”, value);

    }

}

Step 2: Background Timer to Push Updates

var timer = new Timer(async _ =>

{

    var metrics = new Random().Next(0, 100); // mock data

    var hub = app.Services.GetService<IHubContext<MetricsHub>>();

    await hub.Clients.All.SendAsync(“ReceiveMetrics”, metrics);

}, null, 0, 2000);

This pushes a new metric every 2 seconds.

Step 3: Client Dashboard

connection.on(“ReceiveMetrics”, (value) => {

    document.getElementById(“metric”).textContent = value;

});

 

A simple <div id=”metric”>–</div> becomes a live stream.

4. Scaling SignalR (Redis + Azure)

Real-time apps become heavy when thousands of users connect.

SignalR supports horizontal scaling using:

a) Redis Backplane

When you run multiple app instances, messages must sync.

In Program.cs:

builder.Services.AddSignalR()

    .AddStackExchangeRedis(“localhost:6379”);

 

Redis ensures all server instances broadcast messages consistently.

b) Azure SignalR Service

The best managed option for large-scale apps.

Why Xaylon Labs recommends it:

  • Handles auto-scaling

  • Removes WebSocket load from your app

  • Supports millions of connections

  • Integrates with Azure App Service & Containers

Program.cs:

builder.Services.AddSignalR()

    .AddAzureSignalR(“ConnectionString”);

app.MapHub<ChatHub>(“/chatHub”);

 

Deployment becomes effortless.

5. Security & Connection Management

Real-time apps must remain secure and stable.

✔ Use JWT or Cookie Authentication

Secure your hub endpoints:

[Authorize]

public class ChatHub : Hub

{

}

 

✔ Validate messages

Never trust client input.

✔ Limit message size

Configure hub options for safety.

✔ Handle disconnects gracefully

Track when users join/leave using:

public override Task OnConnectedAsync() { … }

public override Task OnDisconnectedAsync(Exception ex) { … }

 

✔ Protect against flooding

Rate-limit message sends.

6. Deploy & Measure Performance

Best Deployment Options

  • Azure App Service

  • Azure Kubernetes Service

  • Docker on Linux VM

  • Cloudflare Tunnel for WebSockets

Performance Tips

  • Enable response compression

  • Use Azure SignalR for high traffic

  • Monitor using Application Insights

  • Keep messages small

  • Use Redis backplane when load balancing

Load Testing Tools

  • K6

  • Azure Load Testing

  • JMeter

Monitoring live connections is crucial once your app hits production.

Conclusion

SignalR unlocks a powerful new layer of real-time user experience that modern applications demand. Whether you’re building a simple chat app or a sophisticated live analytics dashboard, ASP.NET Core + SignalR provides the performance, scalability, security, and developer experience needed to deliver world-class apps.

At Xaylon Labs, we help brands build:

  • Real-time dashboards

  • Collaborative apps

  • Scalable chat systems

  • Live monitoring tools

  • Secure real-time enterprise platforms

If you’re planning a real-time application, SignalR should definitely be in your stack.