$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
.NET / C#intermediateNew

SignalR

Share

Implement real-time communication with SignalR

Works with OpenClaude

You are a .NET backend developer implementing real-time bidirectional communication using SignalR hubs and connections.

What to check first

  • Verify Microsoft.AspNetCore.SignalR NuGet package is installed: dotnet list package
  • Check your ASP.NET Core project targets .NET 6.0 or higher in .csproj
  • Confirm you have a running ASP.NET Core host (Kestrel, IIS, or similar)

Steps

  1. Create a Hub class inheriting from Hub<T> where T is your client interface contract with method signatures clients will call
  2. Implement server-side methods in the Hub that clients can invoke using Clients.All.SendAsync(), Clients.Caller.SendAsync(), or Clients.Others.SendAsync()
  3. Register SignalR in Program.cs using builder.Services.AddSignalR() before building the app
  4. Map the Hub endpoint in middleware with app.MapHub<YourHub>("/hub-path") before app.Run()
  5. Define a public interface on the Hub that declares all client-callable methods with Task return types
  6. Use Clients.Group() and Groups.AddToGroupAsync() to organize clients into named groups for targeted messaging
  7. Implement OnConnectedAsync() and OnDisconnectedAsync() overrides to track connection lifecycle events
  8. Call server methods from clients using the HubConnection object with .InvokeAsync<T>("MethodName", args) or .SendAsync("MethodName", args)

Code

using Microsoft.AspNetCore.SignalR;
using System.Collections.Concurrent;

// Define the client contract interface
public interface IChatClient
{
    Task ReceiveMessage(string user, string message);
    Task UserConnected(string user);
    Task UserDisconnected(string user);
    Task ReceiveNotification(string notification);
}

// Hub implementation
public class ChatHub : Hub<IChatClient>
{
    private static readonly ConcurrentDictionary<string, string> Users = new();

    public override async Task OnConnectedAsync()
    {
        string user = Context.User?.Identity?.Name ?? $"Guest-{Context.ConnectionId}";
        Users.TryAdd(Context.ConnectionId, user);
        
        await Clients.All.UserConnected(user);
        await base.OnConnectedAsync();
    }

    public override async Task OnDisconnectedAsync(Exception? exception)
    {
        if (Users.TryRemove(Context.ConnectionId, out var user))
        {
            await Clients.All.UserDisconnected(user);
        }
        await base.OnDisconnectedAsync(exception);
    }

    public async Task SendMessage(string message)
    {
        if (!Users.TryGetValue(Context.ConnectionId, out var user))

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

Category.NET / C#
Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
dotnetsignalrrealtime

Install command:

curl -o ~/.claude/skills/dotnet-signalr.md https://clskills.in/skills/dotnet/dotnet-signalr.md

Related .NET / C# Skills

Other Claude Code skills in the same category — free to download.

Want a .NET / C# skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.