I have a standard Web Forms application that includes a SignalR hub for JavaScript clients. The hub itself works fine and messages are being sent and received as expected.
When the application is terminated (usually via application pool recycling), I want to send a specific message to all connected SignalR clients. So I hooked into Global.asax's Application_End like this:
void Application_End(object sender, EventArgs e)
{
var hubNotifyTask = Task.Factory.StartNew(() =>
{
IHubContext context = GlobalHost.ConnectionManager.GetHubContext<SiteMasterJsClientHub>();
context.Clients.Group("Group with all users").OnServerStartup("any message");
});
}
Well...this doesn't work. If i put the code outside of Application_End, it works and the clients receive the message. My guess is that SignalR auto-detects the application shutdown and terminates all connections. I haven't found any documentation to verify that though.
So my question is: how can I send an automatic SignalR message just before the application shuts down?
camelCasing. - Rithik BanerjeeOnServerStartupin hub classSiteMasterJsClientHub- Rithik Banerjee