Using a Hub instance not created by the HubPipeline is unsupported.


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

Using a Hub instance not created by the HubPipeline is unsupported

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?


Asked by:- pika
2
: 10305 At:- 9/4/2017 7:58:30 AM
asp-net mvc signalr







1 Answers
profileImage Answered by:- Vipin

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

3
At:- 9/5/2017 11:59:19 AM
thanks, I have already solved the query, but as your above answer is correct, so marked it as correct :) 0
By : pika - at :- 12/29/2017 8:10:02 AM






Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use