Hello, I am trying to call SignalR method from C# controller in asp.net MVC, but I am getting this error
Using a Hub instance not created by the HubPipeline is unsupported.
Here is the image of the error
The C# code using which I am using to Call it is
var broadcast = new chatHub();
broadcast.SendMessage("Here is your Message");
How can I resolve this issue using SignalR in ASP.NET MVC?
This is not the correct way for calling SignalR, it is described here in more detail at http://www.asp.net/signalr/overview/signalr-20/hubs-api/hubs-api-guide-server#callfromoutsidehub
It should be something like this
var broadcast = GlobalHost.ConnectionManager.GetHubContext<chatHub>();
broadcast.Clients.All.SendMessage("Here is your Message");
Clients.All
should address every client that is currently connected to the Hub
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly