ASP.NET Core 2.2.1 Hosting Tips – Getting Started With SignalR Using ASP.NET Core

In this article, we’ll learn how to use Dynamic Hub in ASPNET Core SignalR. The newly written SignalR allows you to write a dynamic type of T Hub. The benefit of using dynamic hub is that the method will resolve to the runtime so that you can register any method at runtime and call it.


Creating Dynamic Hub

This is a base class for SignalR hubs that uses dynamic keyword to represent client invocations. Basically, the idea behind Dynamic Hub is hidden in the dynamic keyword. DynamicHub is inherited from Hub class. This is an abstract class and it is implementing the DynamicHubClients which contains all the dynamic type properties.


“The dynamic type enables the operations in which it occurs to bypass compile-time type checking. Instead, these operations are resolved at runtime. The dynamic type simplifies access to COM APIs such as the Office Automation APIs, and also to dynamic APIs such as IronPython libraries, and to the HTML Document Object Model (DOM).”

A Hub contains the following properties.

  • Clients : A clients caller abstraction for a hub, where you can push message to all connected clients
  • Context : A context abstraction for accessing information about the hub caller connection. It contains the connection and claims principle information.
  • Groups : A manager abstraction for adding and removing connections from groups. Ease of managing clients grouping.
  • Events : It provide the event notification on the client connected or disconnected so that you can override these events and add your custom login.

Dynamic Hub class

DynamicHubClients Class


Dynamic Chat Hub Class

In this hub, we are just sending a message to the client so in the case of Hub, we have to call SendAsync by passing the client method name which is listening to the client and message or other data to send. In case of Dynamic Hub, we can call any method which is bypassed by the compiler because it has dynamic keyword. But that method must be listened to on the client side to receive the data like Send method in above class.

I have created a separate service and component for dynamic hub which is consuming Dynamic Hub for communication and showing the messages. You will find the same in the attached project.

Creating T of Hub

Hub<T> is a base class for a strongly typed SignalR hub where T is type of client. The T typed can be used to invoke a method on clients connected. If you want your strongly typed custom methods, this is for you.

In a Hub, we have to tell in which method client is listening, so that while writing the name of the client method, you can avoid typos and other issues.

We are going to create an Interface called IChatClient.

TChatHub Class

This class is Inherited from strongly typed IChatClient Hub<IChatClient>. In this hub class, you can call IChatClient’s methods on the client. This is the beauty of this Stack. This is just for pushing messages to the connected client.

Finally, we are done with Dynamic and T typed hub in SignalR.

Which Provider who can Give You The Best and Recommended ASP.NET Core 2.2.1 Hosting?

Happily, there are several reliable and recommended Web hosting out there that can help you get a handle on site speed and work to increase your ASP.NET Core 2.2.1 web rank. We are here to recommend you is the most popular choice for people looking to host for the first time at an affordable price in Europe.

Their regular price starts at € 3.49/month only. Customers are allowed to decide on quarterly and annual plan supported their own desires. guarantees “No Hidden Fees” and industry leading ‘30 Days Cash Back’, folks might ask for a full refund if they cancel the service at intervals the first thirty days. also give their customers an opportunity to create some cash by providing reseller hosting accounts. you’ll purchase their reseller hosting account, host unlimited websites thereon and even have the prospect to sell a number of your hosting area to others. This could be one amongst the best ways that of creating some cash on-line. You are doing not have to be compelled to worry concerning hosting stuff as they’ll beware of all the hosting desires of your shoppers.