Search code examples
signalrsignalr-hub

SignalR Hub Overloads


I tried creating a basic hub with two Receive methods, one accepts a string and the other an int. This causes an error stating that the method cannot be resolved. Commenting out one of the methods gets rid of the error and everything works.

Is it possible to have overloads of a method in my hub? Could something like overloads be done?


Solution

  • SignalR does support overloading server-side Hub methods, but the overloads must have a different arity, i.e. take a different number of arguments.

    If the overloads have the same arity, SignalR will be unable to resolve which overload is being called, even though the overloaded Hub methods accept different types.