Skip to content

Commit 859d56a

Browse files
authored
Merge pull request #34599 from dotnet/main
2 parents adc16d2 + 7926160 commit 859d56a

File tree

17 files changed

+730
-66
lines changed

17 files changed

+730
-66
lines changed

aspnetcore/blazor/security/blazor-web-app-with-oidc.md

Lines changed: 186 additions & 3 deletions
Large diffs are not rendered by default.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# [Visual Studio](#tab/visual-studio)
2+
3+
* Press Ctrl+F5 to run without the debugger.
4+
5+
[!INCLUDE[](~/includes/trustCertVS.md)]
6+
7+
Visual Studio:
8+
9+
* Starts [Kestrel](xref:fundamentals/servers/index#kestrel) server.
10+
* Launches a browser.
11+
* Navigates to `http://localhost:port`, such as `http://localhost:7042`.
12+
* *port*: A randomly assigned port number for the app.
13+
* `localhost`: The standard hostname for the local computer. Localhost only serves web requests from the local computer.
14+
15+
# [Visual Studio Code](#tab/visual-studio-code)
16+
17+
[!INCLUDE[](~/includes/trustCertVSC.md)]
18+
19+
* Press **Ctrl-F5** to run without the debugger.
20+
21+
Visual Studio Code:
22+
23+
* Starts [Kestrel](xref:fundamentals/servers/index#kestrel) server.
24+
* Launches a browser.
25+
* Navigates to `http://localhost:port`, such as `http://localhost:7042`.
26+
* *port*: A randomly assigned port number for the app.
27+
* `localhost`: The standard hostname for the local computer. Localhost only serves web requests from the local computer.
28+
29+
---

aspnetcore/security/authentication/configure-jwt-bearer-authentication.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ JWT bearer tokens should be fully validated in an API. The following should be v
125125
* Audience claim with the expected value.
126126
* Token expiration.
127127

128-
The following claims are required for OAuth 2.0 access tokens: `iss`, `exp`, `aud`, `sub`, `client_id`, `iat, and `jti`.
128+
The following claims are required for OAuth 2.0 access tokens: `iss`, `exp`, `aud`, `sub`, `client_id`, `iat`, and `jti`.
129129

130130
If any of these claims or values are incorrect, the API should return a 401 response.
131131

@@ -188,7 +188,7 @@ var requireAuthPolicy = new AuthorizationPolicyBuilder()
188188
.Build();
189189

190190
builder.Services.AddAuthorizationBuilder()
191-
.SetFallbackPolicy(requireAuthPolicy);
191+
.SetDefaultPolicy(requireAuthPolicy);
192192
```
193193

194194
The [Authorize](/dotnet/api/microsoft.aspnetcore.authorization.authorizeattribute) attribute can also be used to force the authentication. If multiple schemes are used, the bearer scheme generally needs to be set as the default authentication scheme or specified via `[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme])`.
@@ -223,7 +223,7 @@ Asymmetric keys should **always** be used when creating access tokens. The publi
223223

224224
### Never create an access token from a username/password request
225225

226-
You should **NOT** create an access token from a username/password request. Username/password requests aren't authenticated and are vunerable to impersonation and phishing attacks. Access tokens should only be created using an OpenID Connect flow or an OAuth standard flow. Deviating from these standards can result in an insecure app.
226+
You should **NOT** create an access token from a username/password request. Username/password requests aren't authenticated and are vulnerable to impersonation and phishing attacks. Access tokens should only be created using an OpenID Connect flow or an OAuth standard flow. Deviating from these standards can result in an insecure app.
227227

228228
### Use cookies
229229

aspnetcore/test/http-files.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ To generate a random integer, use `$randomInt`. The syntax is `{{$randomInt [min
386386

387387
* `$datetime` generates a `datetime` string in UTC. The syntax is `{{$datetime [format] [offset option]}}` where the format and offset options are optional.
388388
* `$localDatetime` generates a `datetime` string in the local time zone. The syntax is `{{$localDatetime [format] [offset option]}}` where the format and offset options are optional.
389-
* `$timeStamp` generates a `timestamp` in UTC. The `timestamp` is the [number of seconds since the Unix Epoch in UTC time](xref:System.DateTimeOffset.ToUnixTimeSeconds?displayProperty=nameWithType). The syntax is `{{$timestamp [offset option]}}` where the offset option is optional.
389+
* `$timestamp` generates a `timestamp` in UTC. The `timestamp` is the [number of seconds since the Unix Epoch in UTC time](xref:System.DateTimeOffset.ToUnixTimeSeconds?displayProperty=nameWithType). The syntax is `{{$timestamp [offset option]}}` where the offset option is optional.
390390

391391
The `[format]` option is one of `rfc1123`, `iso8601`, or a custom format in quotation marks. For example:
392392

aspnetcore/tutorials/grpc/grpc-start.md

Lines changed: 21 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ author: jamesnk
44
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.
55
monikerRange: '>= aspnetcore-3.0'
66
ms.author: wpickett
7-
ms.date: 08/30/2023
7+
ms.date: 01/30/2025
88
uid: tutorials/grpc/grpc-start
99
---
1010
# Tutorial: Create a gRPC client and server in ASP.NET Core
1111

12-
:::moniker range=">= aspnetcore-8.0"
12+
:::moniker range=">= aspnetcore-9.0"
1313
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.
1414

1515
In this tutorial, you:
@@ -23,15 +23,11 @@ In this tutorial, you:
2323

2424
# [Visual Studio](#tab/visual-studio)
2525

26-
[!INCLUDE[](~/includes/net-prereqs-vs-8.0.md)]
26+
[!INCLUDE[](~/includes/net-prereqs-vs-9.0.md)]
2727

2828
# [Visual Studio Code](#tab/visual-studio-code)
2929

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)]
3531

3632
---
3733

@@ -43,13 +39,13 @@ In this tutorial, you:
4339
* In the **Create a new project** dialog, search for `gRPC`. Select **ASP.NET Core gRPC Service** and select **Next**.
4440
* 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.
4541
* 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**.
4743

4844
# [Visual Studio Code](#tab/visual-studio-code)
4945

5046
The tutorial assumes familiarity with VS Code. For more information, see [Getting started with VS Code](https://code.visualstudio.com/docs).
5147

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).
5349
* Change to the directory (`cd`) that will contain the project.
5450
* Run the following commands:
5551

@@ -64,19 +60,11 @@ The tutorial assumes familiarity with VS Code. For more information, see [Gettin
6460

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

67-
# [Visual Studio for Mac](#tab/visual-studio-mac)
68-
69-
* 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-
7563
---
7664

7765
### Run the service
7866

79-
[!INCLUDE[](~/includes/run-the-app6.0.md)]
67+
[!INCLUDE[](~/includes/run-the-app9.0.md)]
8068

8169
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`.
8270

@@ -110,11 +98,11 @@ info: Microsoft.Hosting.Lifetime[0]
11098
* Open a second instance of Visual Studio and select **New Project**.
11199
* In the **Create a new project** dialog, select **Console App**, and select **Next**.
112100
* In the **Project name** text box, enter **GrpcGreeterClient** and select **Next**.
113-
* In the **Additional information** dialog, select **.NET 8.0 (Long Term Support)** and then select **Create**.
101+
* In the **Additional information** dialog, select **.NET 9.0 (Standard Term Support)** and then select **Create**.
114102

115103
# [Visual Studio Code](#tab/visual-studio-code)
116104

117-
* Open the [integrated terminal](https://code.visualstudio.com/docs/editor/integrated-terminal).
105+
* Open the [integrated terminal](https://code.visualstudio.com/docs/terminal/basics).
118106
* Change directories (`cd`) to a folder for the project.
119107
* Run the following commands:
120108

@@ -125,14 +113,6 @@ info: Microsoft.Hosting.Lifetime[0]
125113

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

128-
# [Visual Studio for Mac](#tab/visual-studio-mac)
129-
130-
* In Visual Studio 2022 for Mac select **File** > **Add** > **Project...**.
131-
* In the **Choose a template for your new project** dialog, select **Web and Console** > **App** > **Console Application**, and select **Continue**.
132-
* Select **.NET 8.0** for the target framework, and select **Continue**.
133-
* Name the project **GrpcGreeterClient**. It's important to name the project *GrpcGreeterClient* so the namespaces match when you copy and paste code.
134-
* Select **Continue**.
135-
136116
---
137117

138118
### Add required NuGet packages
@@ -177,15 +157,6 @@ dotnet add GrpcGreeterClient.csproj package Google.Protobuf
177157
dotnet add GrpcGreeterClient.csproj package Grpc.Tools
178158
```
179159

180-
# [Visual Studio for Mac](#tab/visual-studio-mac)
181-
182-
* Right-click **GrpcGreeterClient** project in the **Solution Pad** and select **Manage NuGet Packages**.
183-
* Enter **Grpc.Net.Client** in the search box.
184-
* Select the **Grpc.Net.Client** package from the results pane and select **Add Package**.
185-
* In **Select Projects** select **OK**.
186-
* If the **License Acceptance** dialog appears, select **Accept** if you agree to the license terms.
187-
* Repeat for `Google.Protobuf` and `Grpc.Tools`.
188-
189160
---
190161

191162
### Add greet.proto
@@ -208,10 +179,6 @@ dotnet add GrpcGreeterClient.csproj package Grpc.Tools
208179

209180
Select the `GrpcGreeterClient.csproj` file.
210181

211-
# [Visual Studio for Mac](#tab/visual-studio-mac)
212-
213-
Right-click the project and select **Edit Project File**.
214-
215182
---
216183

217184
* Add an item group with a `<Protobuf>` element that refers to the *greet.proto* file:
@@ -236,7 +203,7 @@ dotnet add GrpcGreeterClient.csproj package Grpc.Tools
236203
237204
* Update the gRPC client `Program.cs` file with the following code.
238205

239-
[!code-csharp[](~/tutorials/grpc/grpc-start/sample/sample8/GrpcGreeterClient/Program.cs?name=snippet2&highlight=6)]
206+
[!code-csharp[](~/tutorials/grpc/grpc-start/sample/sample9/GrpcGreeterClient/Program.cs?name=snippet2&highlight=5)]
240207

241208
* 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.
242209

@@ -247,33 +214,28 @@ The Greeter client is created by:
247214
* Instantiating a `GrpcChannel` containing the information for creating the connection to the gRPC service.
248215
* Using the `GrpcChannel` to construct the Greeter client:
249216

250-
[!code-csharp[](~/tutorials/grpc/grpc-start/sample/sample8/GrpcGreeterClient/Program.cs?name=snippet&highlight=1-3)]
217+
[!code-csharp[](~/tutorials/grpc/grpc-start/sample/sample9/GrpcGreeterClient/Program.cs?name=snippet&highlight=1-3)]
251218

252219
The Greeter client calls the asynchronous `SayHello` method. The result of the `SayHello` call is displayed:
253220

254-
[!code-csharp[](~/tutorials/grpc/grpc-start/sample/sample8/GrpcGreeterClient/Program.cs?name=snippet&highlight=4-7)]
221+
[!code-csharp[](~/tutorials/grpc/grpc-start/sample/sample9/GrpcGreeterClient/Program.cs?name=snippet&highlight=4-6)]
255222

256223
## Test the gRPC client with the gRPC Greeter service
257224

258225
Update the `appsettings.Development.json` file by adding the following highlighted lines:
259226

260-
[!code-csharp[](~/tutorials/grpc/grpc-start/sample/sample8/GrpcGreeter/appsettings.Development.json?highlight=6-7)]
227+
[!code-csharp[](~/tutorials/grpc/grpc-start/sample/sample9/GrpcGreeter/appsettings.Development.json?highlight=6-7)]
261228

262229
# [Visual Studio](#tab/visual-studio)
263230

264-
* 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.
266233

267234
# [Visual Studio Code](#tab/visual-studio-code)
268235

269236
* Start the Greeter service.
270237
* Start the client.
271238

272-
# [Visual Studio for Mac](#tab/visual-studio-mac)
273-
274-
* Start the Greeter service.
275-
* Start the client.
276-
277239
---
278240

279241
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:
@@ -295,13 +257,13 @@ info: Microsoft.Hosting.Lifetime[0]
295257
info: Microsoft.Hosting.Lifetime[0]
296258
Content root path: C:\GH\aspnet\docs\4\Docs\aspnetcore\tutorials\grpc\grpc-start\sample\GrpcGreeter
297259
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
298-
Request starting HTTP/2 POST https://localhost:<port>/Greet.Greeter/SayHello application/grpc
260+
Request starting HTTP/2 POST https://localhost:<port>/greet.Greeter/SayHello application/grpc
299261
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
300-
Executing endpoint 'gRPC - /Greet.Greeter/SayHello'
262+
Executing endpoint 'gRPC - /greet.Greeter/SayHello'
301263
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
302-
Executed endpoint 'gRPC - /Greet.Greeter/SayHello'
264+
Executed endpoint 'gRPC - /greet.Greeter/SayHello'
303265
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
304-
Request finished in 78.32260000000001ms 200 application/grpc
266+
Request finished HTTP/2 POST https://localhost:7042/greet.Greeter/SayHello - 200 - application/grpc 40.4615ms
305267
```
306268

307269
> [!NOTE]
@@ -316,6 +278,8 @@ info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
316278

317279
:::moniker-end
318280

281+
[!INCLUDE[](~/tutorials/grpc/grpc-start/includes/grpc-start8.md)]
282+
319283
[!INCLUDE[](~/tutorials/grpc/grpc-start/includes/grpc-start7.md)]
320284

321285
[!INCLUDE[](~/tutorials/grpc/grpc-start/includes/grpc-start6.md)]

0 commit comments

Comments
 (0)