I am facing an issue in signalr hub from MVC controller. Am facing the below error.
For reference I have added below code used
Controller:
public JsonResult Index(Guid id, string user)
{
HttpStatusCode statusCode;
var hubContext = GlobalHost.ConnectionManager.GetHubContext<NotificationHub>();
NotificationHub hub = new NotificationHub();
hub.AddNotification(user +"| called");
return Json("Success",JsonRequestBehavior.AllowGet);
}
Hub:
public async Task AddNotification(string data) {
if (_connections.Count > 0 )
{
foreach (var connectionId in _connections.GetConnections(_user))
{
await Clients.Client(connectionId).BroadcastNewNotification(_msg);
}
}
}
But Am getting “Object reference not set to an instance of an object” while Broadcast notification
Aucun commentaire:
Enregistrer un commentaire