Configuration changes

In the Startup.cs file, we need to add the SignalR service to the container as well as configure the HTTP request pipeline.

  1. In the ConfigureServices method, add the following code:
services.AddSignalR();
  1. In the Configure method, add the following code:
app.UseSignalR(routes => 
      { 
          routes.MapHub<Chat>("chat"); 
      });

Your code window will now look as follows:

That's our server done.

You will note that I have added the following line of code, app.UseStaticFiles() to the Configure method. Static files are assets that an ASP.NET Core app serves directly to clients. Examples of static files are HTML, CSS, JavaScript, and images. ...

Get C# 7 and .NET Core 2.0 Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.