Skip to content

Commit 0462121

Browse files
CopilotmeaghanlewisCopilot
authored
Update SignalR tutorials for .NET 10 and Visual Studio 2026 (#36695)
* Initial plan * Update SignalR tutorials for .NET 10 and Visual Studio 2026 Co-authored-by: meaghanlewis <10103121+meaghanlewis@users.noreply.github.com> * Update Get started with ASP.NET Core SignalR * rename includes files * update Get started with ASP.NET Core SignalR using TypeScript * fix warning * update code samples * fix link to sample code in repo * Update aspnetcore/tutorials/signalr.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: meaghanlewis <10103121+meaghanlewis@users.noreply.github.com> Co-authored-by: Meaghan Osagie <mosagie@microsoft.com> Co-authored-by: Meaghan Osagie (Lewis) <moneikmarie@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent cfbe598 commit 0462121

65 files changed

Lines changed: 81524 additions & 49 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

aspnetcore/tutorials/signalr-typescript-webpack.md

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
---
22
title: "Tutorial: Get started with ASP.NET Core SignalR using TypeScript and Webpack"
3+
ai-usage: ai-assisted
34
author: ssougnez
45
description: This tutorial provides a walkthrough of bundling and building an ASP.NET Core SignalR web app using TypeScript and Webpack.
5-
monikerRange: ">= aspnetcore-2.1"
66
<!-- ms.author: bradyg -->
7+
monikerRange: ">= aspnetcore-2.1"
78
ms.author: wpickett
89
ms.custom: mvc, engagement-fy23
9-
ms.date: 11/07/2023
10+
ms.date: 01/27/2026
1011
uid: tutorials/signalr-typescript-webpack
1112
---
1213
# Tutorial: Get started with ASP.NET Core SignalR using TypeScript and Webpack
1314

1415
[!INCLUDE[](~/includes/not-latest-version.md)]
1516

16-
By [Sébastien Sougnez](https://twitter.com/s_sougnez)
17-
18-
:::moniker range=">= aspnetcore-8.0"
17+
:::moniker range=">= aspnetcore-10.0"
1918

2019
This tutorial demonstrates using [Webpack](https://webpack.js.org/) in an ASP.NET Core SignalR web app to bundle and build a client written in [TypeScript](https://www.typescriptlang.org/). Webpack enables developers to bundle and build the client-side resources of a web app.
2120

@@ -28,19 +27,19 @@ In this tutorial, you learn how to:
2827
> * Configure the SignalR TypeScript client
2928
> * Enable communication between the client and the server
3029
31-
[View or download sample code](https://github.com/dotnet/AspNetCore.Docs.Samples/tree/main/tutorials/signalr-typescript-webpack/samples) ([how to download](xref:fundamentals/index#how-to-download-a-sample))
30+
[View or download sample code](https://github.com/dotnet/AspNetCore.Docs/tree/main/aspnetcore/tutorials/signalr-typescript-webpack/samples) ([how to download](xref:fundamentals/index#how-to-download-a-sample))
3231

3332
## Prerequisites
3433

3534
* [Node.js](https://nodejs.org/) with [npm](https://www.npmjs.com/)
3635

3736
# [Visual Studio](#tab/visual-studio)
3837

39-
[!INCLUDE[](~/includes/net-prereqs-vs-8.0.md)]
38+
[!INCLUDE[](~/includes/net-prereqs-vs-10.md)]
4039

4140
# [Visual Studio Code](#tab/visual-studio-code)
4241

43-
[!INCLUDE[](~/includes/net-prereqs-vsc-8.0.md)]
42+
[!INCLUDE[](~/includes/net-prereqs-vsc-10.0.md)]
4443

4544
---
4645

@@ -50,28 +49,32 @@ In this tutorial, you learn how to:
5049

5150
By default, Visual Studio uses the version of npm found in its installation directory. To configure Visual Studio to look for npm in the `PATH` environment variable:
5251

53-
Launch Visual Studio. At the start window, select **Continue without code**.
52+
Launch the latest version of Visual Studio. At the start window, select **Continue without code**.
5453

5554
1. Navigate to **Tools** > **Options** > **Projects and Solutions** > **Web Package Management** > **External Web Tools**.
5655
1. Select the `$(PATH)` entry from the list. Select the up arrow to move the entry to the second position in the list, and select **OK**:
5756

58-
![Visual Studio Configuration](~/tutorials/signalr-typescript-webpack/_static/8.x/signalr-configure-path-visual-studio-v17.8.0.png).
57+
:::image type="content" source="~/tutorials/signalr-typescript-webpack/media/configure-path.png" alt-text="Visual Studio Configuration.":::
5958

6059
To create a new ASP.NET Core web app:
6160

62-
1. Use the **File** > **New** > **Project** menu option and choose the **ASP.NET Core Empty** template. Select **Next**.
63-
1. Name the project `SignalRWebpack`, and select **Create**.
64-
1. Select **.NET 8.0 (Long Term Support)** from the **Framework** drop-down. Select **Create**.
61+
1. Use the **File** > **New** > **Project/Solution...** menu option.
62+
1. In the **Create a new project** dialog, select **ASP.NET Core Empty** template. Then select **Next**.
63+
1. In the **Configure your new project** dialog, enter `SignalRWebpack` for **Project name**. Select **Next**.
64+
1. In the **Additional information** dialog, select **.NET 10.0 (Long Term Support)** from the **Framework** drop-down. Select **Create**.
6565

6666
Add the [Microsoft.TypeScript.MSBuild](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild/) NuGet package to the project:
6767

68-
1. In **Solution Explorer**, right-click the project node and select **Manage NuGet Packages**. In the **Browse** tab, search for `Microsoft.TypeScript.MSBuild` and then select **Install** on the right to install the package.
68+
1. In **Solution Explorer**, right-click the project node and select **Manage NuGet Packages...**.
69+
1. In the **Browse** tab, search for `Microsoft.TypeScript.MSBuild` and then select **Install** on the right to install the package.
70+
1. In the **Preview Changes** dialog, select **Apply**.
71+
1. In the **License Acceptance** dialog, select **I Accept**.
6972

7073
Visual Studio adds the NuGet package under the **Dependencies** node in **Solution Explorer**, enabling TypeScript compilation in the project.
7174

7275
# [Visual Studio Code](#tab/visual-studio-code)
7376

74-
Run the following commands in the **Integrated Terminal**:
77+
Run the following commands in the **Terminal**:
7578

7679
```dotnetcli
7780
dotnet new web -o SignalRWebpack
@@ -83,7 +86,7 @@ code -r SignalRWebpack
8386

8487
[!INCLUDE[](~/includes/vscode-trust-authors-add-assets.md)]
8588

86-
Run the following .NET CLI command in the **Integrated Terminal**:
89+
Run the following .NET CLI command in the **Terminal**:
8790

8891
```dotnetcli
8992
dotnet add package Microsoft.TypeScript.MSBuild
@@ -99,19 +102,19 @@ In this section, you configure the ASP.NET Core web app to send and receive Sign
99102

100103
1. In `Program.cs`, call <xref:Microsoft.Extensions.DependencyInjection.SignalRDependencyInjectionExtensions.AddSignalR%2A>:
101104

102-
[!code-csharp[](~/../AspNetCore.Docs.Samples/tutorials/signalr-typescript-webpack/samples/8.x/SignalRWebpack/Program.cs?name=snippet_AddSignalR&highlight=3)]
105+
[!code-csharp[](~/tutorials/signalr-typescript-webpack/samples/10.x/Program.cs?name=snippet_AddSignalR&highlight=3)]
103106

104107
1. Again, in `Program.cs`, call <xref:Microsoft.AspNetCore.Builder.DefaultFilesExtensions.UseDefaultFiles%2A> and <xref:Microsoft.AspNetCore.Builder.StaticFileExtensions.UseStaticFiles%2A>:
105108

106-
[!code-csharp[](~/../AspNetCore.Docs.Samples/tutorials/signalr-typescript-webpack/samples/8.x/SignalRWebpack/Program.cs?name=snippet_FilesMiddleware&highlight=3-4)]
109+
[!code-csharp[](~/tutorials/signalr-typescript-webpack/samples/10.x/Program.cs?name=snippet_FilesMiddleware&highlight=3-4)]
107110

108111
The preceding code allows the server to locate and serve the `index.html` file. The file is served whether the user enters its full URL or the root URL of the web app.
109112

110113
1. Create a new directory named `Hubs` in the project root, `SignalRWebpack/`, for the SignalR hub class.
111114

112115
1. Create a new file, `Hubs/ChatHub.cs`, with the following code:
113116

114-
[!code-csharp[](~/../AspNetCore.Docs.Samples/tutorials/signalr-typescript-webpack/samples/8.x/SignalRWebpack/Hubs/ChatHub.cs)]
117+
[!code-csharp[](~/tutorials/signalr-typescript-webpack/samples/10.x/Hubs/ChatHub.cs)]
115118

116119
The preceding code broadcasts received messages to all connected users once the server receives them. It's unnecessary to have a generic `on` method to receive all the messages. A method named after the message name is enough.
117120

@@ -124,11 +127,11 @@ In this section, you configure the ASP.NET Core web app to send and receive Sign
124127

125128
1. Add the following `using` statement at the top of `Program.cs` to resolve the `ChatHub` reference:
126129

127-
[!code-csharp[](~/../AspNetCore.Docs.Samples/tutorials/signalr-typescript-webpack/samples/8.x/SignalRWebpack/Program.cs?name=snippet_HubsNamespace)]
130+
[!code-csharp[](~/tutorials/signalr-typescript-webpack/samples/10.x/Program.cs?name=snippet_HubsNamespace)]
128131

129132
1. In `Program.cs`, map the `/hub` route to the `ChatHub` hub. Replace the code that displays `Hello World!` with the following code:
130133

131-
[!code-csharp[](~/../AspNetCore.Docs.Samples/tutorials/signalr-typescript-webpack/samples/8.x/SignalRWebpack/Program.cs?name=snippet_MapHub)]
134+
[!code-csharp[](~/tutorials/signalr-typescript-webpack/samples/10.x/Program.cs?name=snippet_MapHub)]
132135

133136
## Configure the client
134137

@@ -142,7 +145,7 @@ In this section, you create a [Node.js](https://nodejs.org/) project to convert
142145

143146
1. Add the highlighted property to the `package.json` file and save the file changes:
144147

145-
[!code-json[](~/../AspNetCore.Docs.Samples/tutorials/signalr-typescript-webpack/samples_snapshot/8.x/package.json?highlight=4)]
148+
[!code-json[](~/tutorials/signalr-typescript-webpack/samples/10.x/package.json?highlight=4)]
146149

147150
Setting the `private` property to `true` prevents package installation warnings in the next step.
148151

@@ -158,7 +161,7 @@ In this section, you create a [Node.js](https://nodejs.org/) project to convert
158161

159162
1. Replace the `scripts` property of `package.json` file with the following code:
160163

161-
[!code-json[](~/../AspNetCore.Docs.Samples/tutorials/signalr-typescript-webpack/samples/8.x/SignalRWebpack/package.json?range=7-11)]
164+
[!code-json[](~/tutorials/signalr-typescript-webpack/samples/10.x/package.json?range=7-11)]
162165

163166
The following scripts are defined:
164167

@@ -168,7 +171,7 @@ In this section, you create a [Node.js](https://nodejs.org/) project to convert
168171

169172
1. Create a file named `webpack.config.js` in the project root, with the following code:
170173

171-
[!code-javascript[](~/../AspNetCore.Docs.Samples/tutorials/signalr-typescript-webpack/samples/8.x/SignalRWebpack/webpack.config.js)]
174+
[!code-javascript[](~/tutorials/signalr-typescript-webpack/samples/10.x/webpack.config.js)]
172175

173176
The preceding file configures the Webpack compilation process:
174177

@@ -177,23 +180,23 @@ In this section, you create a [Node.js](https://nodejs.org/) project to convert
177180

178181
1. Create a new directory named `src` in the project root, `SignalRWebpack/`, for the client code.
179182
180-
1. Copy the `src` directory and its contents from the [sample project](https://github.com/dotnet/AspNetCore.Docs.Samples/tree/main/tutorials/signalr-typescript-webpack/samples/8.x/SignalRWebpack/) into the project root. The `src` directory contains the following files:
183+
1. Copy the `src` directory and its contents from the [sample project](https://github.com/dotnet/AspNetCore.Docs/tree/main/aspnetcore/tutorials/signalr-typescript-webpack/samples/) into the project root. The `src` directory contains the following files:
181184

182185
* `index.html`, which defines the homepage's boilerplate markup:
183186

184-
[!code-html[](~/../AspNetCore.Docs.Samples/tutorials/signalr-typescript-webpack/samples/8.x/SignalRWebpack/src/index.html)]
187+
[!code-html[](~/tutorials/signalr-typescript-webpack/samples/10.x/src/index.html)]
185188

186189
* `css/main.css`, which provides CSS styles for the homepage:
187190

188-
[!code-css[](~/../AspNetCore.Docs.Samples/tutorials/signalr-typescript-webpack/samples/8.x/SignalRWebpack/src/css/main.css)]
191+
[!code-css[](~/tutorials/signalr-typescript-webpack/samples/10.x/src/css/main.css)]
189192

190193
* `tsconfig.json`, which configures the TypeScript compiler to produce [ECMAScript](https://wikipedia.org/wiki/ECMAScript) 5-compatible JavaScript:
191194

192-
[!code-json[](~/../AspNetCore.Docs.Samples/tutorials/signalr-typescript-webpack/samples/8.x/SignalRWebpack/src/tsconfig.json)]
195+
[!code-json[](~/tutorials/signalr-typescript-webpack/samples/10.x/src/tsconfig.json)]
193196

194197
* `index.ts`:
195198

196-
[!code-typescript[](~/../AspNetCore.Docs.Samples/tutorials/signalr-typescript-webpack/samples/8.x/SignalRWebpack/src/index.ts)]
199+
[!code-typescript[](~/tutorials/signalr-typescript-webpack/samples/10.x/src/index.ts)]
197200

198201
The preceding code retrieves references to DOM elements and attaches two event handlers:
199202

@@ -257,7 +260,7 @@ Confirm that the app works with the following steps:
257260

258261
---
259262

260-
![Message displayed in both browser windows](~/tutorials/signalr-typescript-webpack/_static/browsers-message-broadcast.png)
263+
:::image type="content" source="~/tutorials/signalr-typescript-webpack/media/browser-message-broadcast.png" alt-text="Message displayed in both browser windows.":::
261264

262265
## Next steps
263266

@@ -272,6 +275,8 @@ Confirm that the app works with the following steps:
272275

273276
:::moniker-end
274277

278+
[!INCLUDE[](~/tutorials/signalr-typescript-webpack/includes/signalr-typescript-webpack8-9.md)]
279+
275280
[!INCLUDE[](~/tutorials/signalr-typescript-webpack/includes/signalr-typescript-webpack7.md)]
276281

277282
[!INCLUDE[](~/tutorials/signalr-typescript-webpack/includes/signalr-typescript-webpack6.md)]

0 commit comments

Comments
 (0)