Q:

Send message to all open clients in browser when they're logged in

I got a website in ASP.NET MVC 3.
People can send messages to other peoples inbox and at the moment the only way they get notified is when they a) login, b) do a refresh with post back c) through mail.
But how do I get to send a notification to the right person (httpcontext.identy.user.name is unique if that helps?) and post it on their screen.

A:

You can either use WebSockets to push new messages to all users or use ajax polling and check for new messages at a regular interval.
The easiest way would be to implement this using SignalR, which uses WebSockets or defaults to long polling if WebSockets is not available.
I would recommend going through the SignalR Getting Started guide. There is also a sample which is available via Nuget, named SignalR.Sample.

