In the Startup.cs file, we need to add the SignalR Service to the container, as well as configure the HTTP request pipeline. Let's get started:
- In the ConfigureServices method, add the following code:
services.AddSignalR().AddAzureSignalR();
- In the Configure method, add the following code:
app.UseDefaultFiles();app.UseStaticFiles();
app.UseAzureSignalR(r =>
{
r.MapHub<Chat>("/chat");
});
Note that we have added app.UseStaticFiles() to the Configure method. Static files are assets that an ASP.NET Core app serves directly to clients. Examples of static files include HTML, CSS, JavaScript, and images. The call to app.UseDefaultFiles() (which must be called prior to app.UseStaticFiles()) tells the middleware to search ...