0Pricing
C# Academy · Lesson

Strongly Typed Hubs

Define typed hub interfaces to get compile-time safety and IntelliSense for client method calls.

The Problem with String Method Names

Standard SignalR calls use SendAsync("MethodName", ...) with magic strings. A typo in the method name causes a silent failure — the client simply never receives the message. Strongly typed hubs solve this.

Defining the Client Interface

Create an interface that declares every method the server can invoke on the client. The method names and parameter types are your contract.

// INotificationClient.cs
public interface INotificationClient
{
    Task ReceiveMessage(string user, string message);
    Task OrderShipped(int orderId, string trackingNumber);
    Task UserJoined(string username);
    Task UserLeft(string username);
    Task SystemAlert(string message);
}

All lessons in this course

  1. SignalR Hubs & Connections
  2. Groups, Users & Connection Management
  3. Strongly Typed Hubs
  4. Scaling with Redis Backplane
← Back to C# Academy