How to broadcast a message from outside SignalR hub

Broadcasting a message from SignalR hub is pretty straight forward, but sometimes you may need to do the same from outside the hub, like from MVC controller or a Web Page.

This snippet will help you to broadcast messages from outside hub.

var context = GlobalHost.ConnectionManager.GetHubContext<MySampleHub>();
Context.Clients.All.Notify("Notification from Server");

In this MySampleHub is the SignalR hub class and Notify is the Hub method.

Happy Programming