How to broadcast a message from outside SignalR hub

October 08, 2013 by Anuraj

.Net .Net 4.0 ASP.Net MVC

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

Copyright © 2024 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub