Generating static files for JavaScript proxies
One of the most fascinating things about SignalR is its ability to generate JavaScript dynamic proxies on the fly for any server-side Hub. These proxies make writing client-side code very easy and natural, but there's a price to pay, because the dynamic endpoint has to generate all the necessary plumbing code on the fly when requested. Although SignalR optimizes this process with caching strategies, this approach cannot be as efficient as a static and cacheable file. For this reason, SignalR's team decided to provide a way to distribute JavaScript dynamic proxies through a statically generated script.
In this recipe, we'll write a very basic application using dynamic proxies, and then we'll rework it to replace the dynamic endpoint with an equivalent static file.
Getting ready
Before writing the code of this recipe, we need to create a new empty web application, which we'll call Recipe33
.
How to do it…
Let's quickly build our sample project using...