Preparing our web application for SignalR
We now have the dependencies set up as required so all we need now is to prepare our web application for SignalR.
Making your SignalR hubs available for the client
Any hubs that we create need to be exposed to any connecting client so that they can be used. Let's start by exposing any SignalR hubs that we add from this point to automatically be available for our client. Open up the Startup.cs
file. At the bottom of the Configuration
method, we need to add a call to map any SignalR hubs, as shown in the following code:
public void Configuration(IAppBuilder app) { ConfigureAuth(app); App.MapSignalR(); }
Note
It's possible to specify a base URL in the MapSignalR()
method call that enables you to expose SignalR at whichever route you see fit.
By default, SignalR uses something called
Open Web Interface for .NET (OWIN) and it needs to be told what the starting point is. Notice this is at the top of the Startup.cs
file, above the namespace declaration...