You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: aspnetcore/tutorials/grpc/grpc-start.md
+21-57
Original file line number
Diff line number
Diff line change
@@ -4,12 +4,12 @@ author: jamesnk
4
4
description: This tutorial shows how to create a gRPC Service and gRPC client on ASP.NET Core. Learn how to create a gRPC Service project, edit a proto file, and add a duplex streaming call.
5
5
monikerRange: '>= aspnetcore-3.0'
6
6
ms.author: wpickett
7
-
ms.date: 08/30/2023
7
+
ms.date: 01/30/2025
8
8
uid: tutorials/grpc/grpc-start
9
9
---
10
10
# Tutorial: Create a gRPC client and server in ASP.NET Core
11
11
12
-
:::moniker range=">= aspnetcore-8.0"
12
+
:::moniker range=">= aspnetcore-9.0"
13
13
This tutorial shows how to create a .NET Core [gRPC](xref:grpc/index) client and an ASP.NET Core gRPC Server. At the end, you'll have a gRPC client that communicates with the gRPC Greeter service.
14
14
15
15
In this tutorial, you:
@@ -23,15 +23,11 @@ In this tutorial, you:
23
23
24
24
# [Visual Studio](#tab/visual-studio)
25
25
26
-
[!INCLUDE[](~/includes/net-prereqs-vs-8.0.md)]
26
+
[!INCLUDE[](~/includes/net-prereqs-vs-9.0.md)]
27
27
28
28
# [Visual Studio Code](#tab/visual-studio-code)
29
29
30
-
[!INCLUDE[](~/includes/net-prereqs-vsc-8.0.md)]
31
-
32
-
# [Visual Studio for Mac](#tab/visual-studio-mac)
33
-
34
-
[!INCLUDE[](~/includes/net-prereqs-mac-8.0.md)]
30
+
[!INCLUDE[](~/includes/net-prereqs-vsc-9.0.md)]
35
31
36
32
---
37
33
@@ -43,13 +39,13 @@ In this tutorial, you:
43
39
* In the **Create a new project** dialog, search for `gRPC`. Select **ASP.NET Core gRPC Service** and select **Next**.
44
40
* In the **Configure your new project** dialog, enter `GrpcGreeter` for **Project name**. It's important to name the project *GrpcGreeter* so the namespaces match when you copy and paste code.
45
41
* Select **Next**.
46
-
* In the **Additional information** dialog, select **.NET 8.0 (Long Term Support)** and then select **Create**.
42
+
* In the **Additional information** dialog, select **.NET 9.0 (Standard Term Support)** and then select **Create**.
47
43
48
44
# [Visual Studio Code](#tab/visual-studio-code)
49
45
50
46
The tutorial assumes familiarity with VS Code. For more information, see [Getting started with VS Code](https://code.visualstudio.com/docs).
51
47
52
-
* Select **New Terminal** from the **Terminal** menu to open the [integrated terminal](https://code.visualstudio.com/docs/editor/integrated-terminal).
48
+
* Select **New Terminal** from the **Terminal** menu to open the [integrated terminal](https://code.visualstudio.com/docs/terminal/basics).
53
49
* Change to the directory (`cd`) that will contain the project.
54
50
* Run the following commands:
55
51
@@ -64,19 +60,11 @@ The tutorial assumes familiarity with VS Code. For more information, see [Gettin
* Start Visual Studio 2022 for Mac and select **File** > **New Project**.
70
-
* In the **Choose a template for your new project** dialog, select **Web and Console** > **App** > **gRPC Service** and select **Continue**.
71
-
* Select **.NET 8.0** for the target framework and select **Continue**.
72
-
* Name the project **GrpcGreeter**. It's important to name the project *GrpcGreeter* so the namespaces match when you copy and paste code.
73
-
* Select **Continue**.
74
-
75
63
---
76
64
77
65
### Run the service
78
66
79
-
[!INCLUDE[](~/includes/run-the-app6.0.md)]
67
+
[!INCLUDE[](~/includes/run-the-app9.0.md)]
80
68
81
69
The logs show the service listening on `https://localhost:<port>`, where `<port>` is the localhost port number randomly assigned when the project is created and set in `Properties/launchSettings.json`.
* In the preceding highlighted code, replace the localhost port number `7042` with the `HTTPS` port number specified in `Properties/launchSettings.json` within the `GrpcGreeter` service project.
242
209
@@ -247,33 +214,28 @@ The Greeter client is created by:
247
214
* Instantiating a `GrpcChannel` containing the information for creating the connection to the gRPC service.
248
215
* Using the `GrpcChannel` to construct the Greeter client:
* In the Greeter service, press `Ctrl+F5` to start the server without the debugger.
265
-
* In the `GrpcGreeterClient` project, press `Ctrl+F5` to start the client without the debugger.
231
+
* In the `GrpcGreeter` service project, press `Ctrl+F5` to start the server without the debugger.
232
+
* In the `GrpcGreeterClient`console project, press `Ctrl+F5` to start the client without the debugger.
266
233
267
234
# [Visual Studio Code](#tab/visual-studio-code)
268
235
269
236
* Start the Greeter service.
270
237
* Start the client.
271
238
272
-
# [Visual Studio for Mac](#tab/visual-studio-mac)
273
-
274
-
* Start the Greeter service.
275
-
* Start the client.
276
-
277
239
---
278
240
279
241
The client sends a greeting to the service with a message containing its name, *GreeterClient*. The service sends the message "Hello GreeterClient" as a response. The "Hello GreeterClient" response is displayed in the command prompt:
0 commit comments