How to broadcast a message from outside SignalR hub

Posted by Anuraj on Tuesday, October 8, 2013 Reading time :1 minute

.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

What do you think? I would like to hear your thoughts, suggestions, and questions in the comments section below.

Did you like this article? Share it with your friends

Facebook Twitter Google+ LinkedIn Reddit StumbleUpon

BMC logoBuy me a coffee

Copyright © 2019 - Anuraj P. 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. Hosted with ❤ by GitHub