So what exactly is SignalR, and how can you use it in your work? Mike Brind, a Microsoft blogger, offers a very extensive explanation in a recent blog post, complete with a couple of full-fledged code tutorials that show you how to build useful applications with it. Basically, SignalR makes it easier for you to write programs that provide automatic data updates.
On the surface, this might not seem like a big deal, but real-time updates actually go against the typical way the web works. As Brind explains, what normally happens is that a browser (or other client or user agent) makes a request, and a web server responds to that request. One request yields one response – and web servers won’t respond unless they’ve received a request. So how do you go about displaying real-time updates on your web page?
Brind lists a number of techniques developers use, such as repeatedly polling the server using AJAX to discover changes to data; keeping a persistent connection open between the client and the server by using Comet technology; and, courtesy of HTML 5, Server Sent Events and WebSockets. SignalR is Microsoft’s solution to this issue.
So what exactly is SignalR? According to Brind, “SignalR is a user-friendly wrapper around all these technologies that makes it a lot easier to create applications that require the real-time display of data. SignalR utilises HTML4 web Sockets API where it is available, and falls back onto other technologies where they are not – Server Sent Events, Forever Frames or Long Polling, the last two of which are Comet techniques.”
It makes perfect sense that Microsoft would add SignalR to ASP.NET as part of its overall updating of tools in the face of Windows 8. If you’ve ever used the new operating system, or even just seen it running, you know that it features lots of small applications that Microsoft intends for its users to keep discreetly open most of the time. These applications update in real time, allowing a user to notice instantly when they receive a new e-mail message, for example, or see which of their friends are online at any given time.
With the software giant banking so much on the success of Windows 8, it is also depending on developers to come through for it with real-time applications that work with the OS. The least the company can do is update its important tools and frameworks, like ASP.NET, to make it easy for programmers to include what Microsoft hopes will become a signature behavior of Windows 8: namely, real-time updates of applications via the web.
You can visit SignalR on Nuget or on Github for updates and to download the release candidate. But check Brind’s post for his recommendations of how to obtain and install the this prerelease version of SignalR. He notes that “you can get it using Visual Studio (and Express For Web version, which is free) if you choose ‘Include Prerelease’ instead of the default ‘Stable Only’ option.” Since web applications updated in real time seem to be the wave of the future, you might as well get on board. Good luck!