Skip to content

Commit 39c4459

Browse files
authored
Merge pull request #94583 from sffamily/optimize_structure
updating for ASP.NET Core 3
2 parents 8b21ef5 + 56af5a2 commit 39c4459

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

articles/azure-signalr/signalr-quickstart-dotnet-core.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ author: sffamily
55
ms.service: signalr
66
ms.devlang: dotnet
77
ms.topic: quickstart
8-
ms.date: 03/01/2019
8+
ms.date: 11/04/2019
99
ms.author: zhshang
1010
---
1111
# Quickstart: Create a chat room by using SignalR Service
1212

1313

14-
Azure SignalR Service is an Azure service that helps developers easily build web applications with real-time features. This service is based on [SignalR for ASP.NET Core 2.0](https://docs.microsoft.com/aspnet/core/signalr/introduction).
14+
Azure SignalR Service is an Azure service that helps developers easily build web applications with real-time features. This service is based on [SignalR for ASP.NET Core 2.1](https://docs.microsoft.com/aspnet/core/signalr/introduction?view=aspnetcore-2.1), but also supports [SignalR for ASP.NET Core 3.0](https://docs.microsoft.com/aspnet/core/signalr/introduction?view=aspnetcore-3.0).
1515

1616
This article shows you how to get started with the Azure SignalR Service. In this quickstart, you'll create a chat application by using an ASP.NET Core MVC web app. This app will make a connection with your Azure SignalR Service resource to enable real-time content updates. You'll host the web application locally and connect with multiple browser clients. Each client will be able to push content updates to all other clients.
1717

@@ -89,7 +89,7 @@ In this section, you'll add the [Secret Manager tool](https://docs.microsoft.com
8989
This secret is accessed with the Configuration API. A colon (:) works in the configuration name with the Configuration API on all supported platforms. See [Configuration by environment](https://docs.microsoft.com/aspnet/core/fundamentals/configuration/index?tabs=basicconfiguration&view=aspnetcore-2.0).
9090

9191

92-
4. Open *Startup.cs* and update the `ConfigureServices` method to use Azure SignalR Service by calling the `services.AddSignalR().AddAzureSignalR()` method:
92+
4. Open *Startup.cs* and update the `ConfigureServices` method to use Azure SignalR Service by calling the `services.AddSignalR().AddAzureSignalR()` method for ASP.NET Core 2 only:
9393

9494
```csharp
9595
public void ConfigureServices(IServiceCollection services)
@@ -98,10 +98,11 @@ In this section, you'll add the [Secret Manager tool](https://docs.microsoft.com
9898
services.AddSignalR().AddAzureSignalR();
9999
}
100100
```
101+
For ASP.NET Core 3+, there is no change needed for `ConfigureServices` method.
101102

102103
By not passing a parameter to `AddAzureSignalR()`, this code uses the default configuration key for the SignalR Service resource connection string. The default configuration key is *Azure:SignalR:ConnectionString*.
103104

104-
5. Also in *Startup.cs*, update the `Configure` method by replacing the call to `app.UseStaticFiles()` with the following code and save the file.
105+
5. Also in *Startup.cs*, update the `Configure` method by replacing the call to `app.UseStaticFiles()` with the following code and save the file, for ASP.NET Core 2 only.
105106

106107
```csharp
107108
app.UseFileServer();
@@ -110,6 +111,18 @@ In this section, you'll add the [Secret Manager tool](https://docs.microsoft.com
110111
routes.MapHub<Chat>("/chat");
111112
});
112113
```
114+
For ASP.NET Core 3+, replace the above code with:
115+
116+
```csharp
117+
app.UseFileServer();
118+
app.UseRouting();
119+
app.UseAuthorization();
120+
121+
app.UseEndpoints(routes =>
122+
{
123+
routes.MapHub<Chat>("/chat");
124+
});
125+
```
113126

114127
### Add a hub class
115128

0 commit comments

Comments
 (0)