Skip to content

Commit 2ebe6cf

Browse files
authored
Merge pull request #36694 from dotnet/main
Merge to Live
2 parents 08e9612 + f39106a commit 2ebe6cf

155 files changed

Lines changed: 79459 additions & 186 deletions

File tree

Some content is hidden

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

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: Secure an ASP.NET Core Blazor Web App with Microsoft Entra ID
3+
ai-usage: ai-assisted
34
author: guardrex
45
description: Learn how to secure a Blazor Web App with Microsoft Entra ID.
56
monikerRange: '>= aspnetcore-9.0'
@@ -1150,6 +1151,12 @@ Alternatively, use the following `LogInOrOut` component, which doesn't supply a
11501151
11511152
For more information on how this app secures its weather data, see [Secure data in Blazor Web Apps with Interactive Auto rendering](xref:blazor/security/index#secure-data-in-blazor-web-apps-with-interactive-auto-rendering).
11521153
1154+
## Host in a web farm or cluster
1155+
1156+
Server-side Blazor Web Apps hosted in a web farm or cluster of machines must adopt [*session affinity*](xref:blazor/fundamentals/signalr#use-session-affinity-sticky-sessions-for-server-side-web-farm-hosting) to maintain Blazor circuits for users of the app.
1157+
1158+
We also recommend using a shared [Data Protection](xref:security/data-protection/introduction) key ring in production, even when the app uses the Interactive WebAssembly render mode exclusively for client-side rendering (no Blazor circuits).
1159+
11531160
## Troubleshoot
11541161
11551162
[!INCLUDE[](~/blazor/security/includes/troubleshoot-server.md)]
@@ -1164,3 +1171,7 @@ For more information on how this app secures its weather data, see [Secure data
11641171
* [`AuthenticationStateProvider` service](xref:blazor/security/index#authenticationstateprovider-service)
11651172
* [Manage authentication state in Blazor Web Apps](xref:blazor/security/index#manage-authentication-state-in-blazor-web-apps)
11661173
* [Service abstractions in Blazor Web Apps](xref:blazor/call-web-api#service-abstractions-for-web-api-calls)
1174+
* Data Protection resources
1175+
* <xref:security/data-protection/configuration/overview>
1176+
* <xref:security/data-protection/implementation/key-storage-providers>
1177+
* <xref:security/data-protection/implementation/key-encryption-at-rest>

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: Secure an ASP.NET Core Blazor Web App with OpenID Connect (OIDC)
3+
ai-usage: ai-assisted
34
author: guardrex
45
description: Learn how to secure a Blazor Web App with OpenID Connect (OIDC).
56
monikerRange: '>= aspnetcore-8.0'
@@ -1488,6 +1489,16 @@ The [typed HTTP client](xref:blazor/call-web-api#typed-httpclient) (or [named HT
14881489

14891490
For more information, see the [Duende Access Token Management documentation for Blazor](https://docs.duendesoftware.com/accesstokenmanagement/blazor-server/).
14901491

1492+
## Host in a web farm or cluster
1493+
1494+
Server-side Blazor Web Apps hosted in a web farm or cluster of machines must adopt [*session affinity*](xref:blazor/fundamentals/signalr#use-session-affinity-sticky-sessions-for-server-side-web-farm-hosting) to maintain Blazor circuits for users of the app.
1495+
1496+
We also recommend using a shared [Data Protection](xref:security/data-protection/introduction) key ring in production, even when the app uses the Interactive WebAssembly render mode exclusively for client-side rendering (no Blazor circuits). For more information, see the following articles:
1497+
1498+
* <xref:security/data-protection/configuration/overview>
1499+
* <xref:security/data-protection/implementation/key-storage-providers>
1500+
* <xref:security/data-protection/implementation/key-encryption-at-rest>
1501+
14911502
## Troubleshoot
14921503

14931504
[!INCLUDE[](~/blazor/security/includes/troubleshoot-server.md)]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Run the following .NET CLI commands:
2+
3+
```dotnetcli
4+
dotnet tool uninstall --global dotnet-aspnet-codegenerator
5+
dotnet tool install --global dotnet-aspnet-codegenerator
6+
dotnet tool uninstall --global dotnet-ef
7+
dotnet tool install --global dotnet-ef
8+
dotnet add package Microsoft.EntityFrameworkCore.Design
9+
dotnet add package Microsoft.EntityFrameworkCore.SQLite
10+
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
11+
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
12+
dotnet add package Microsoft.EntityFrameworkCore.Tools
13+
```
14+
15+
The preceding commands add:
16+
* The [command-line interface (CLI) tools for EF Core](/ef/core/miscellaneous/cli/dotnet)
17+
* The [aspnet-codegenerator scaffolding tool](xref:fundamentals/tools/dotnet-aspnet-codegenerator).
18+
* Design time tools for EF Core
19+
* The EF Core SQLite provider, which installs the EF Core package as a dependency.
20+
* Packages needed for scaffolding: `Microsoft.VisualStudio.Web.CodeGeneration.Design` and `Microsoft.EntityFrameworkCore.SqlServer`.
21+
22+
For guidance on multiple environment configuration that permits an app to configure its database contexts by environment, see <xref:fundamentals/environments#environment-based-startup-class-and-methods>.
23+
24+
[!INCLUDE[](~/includes/dotnet-tool-install-arch-options.md)]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
* [Visual Studio 2026](https://visualstudio.microsoft.com/downloads/) with the **ASP.NET and web development** workload.
1+
* [The latest version of Visual Studio](https://visualstudio.microsoft.com/downloads/) with the **ASP.NET and web development** workload.
22

3-
:::image type="content" source="~/tutorials/min-web-api/_static/asp-net-web-dev-2026.png" alt-text="VS22 installer workloads" lightbox="~/tutorials/min-web-api/_static/asp-net-web-dev-2026.png":::
3+
:::image type="content" source="~/tutorials/min-web-api/_static/asp-net-web-dev-2026.png" alt-text="VS26 installer workloads" lightbox="~/tutorials/min-web-api/_static/asp-net-web-dev-2026.png":::

aspnetcore/tutorials/first-mvc-app/adding-controller.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Part 2, add a controller to an ASP.NET Core MVC app
33
author: wadepickett
44
description: Part 2 of tutorial series on ASP.NET Core MVC.
55
ms.author: wpickett
6-
ms.date: 03/26/2025
6+
ms.date: 01/22/2026
77
monikerRange: '>= aspnetcore-3.1'
88
uid: tutorials/first-mvc-app/adding-controller
99
---
@@ -12,9 +12,7 @@ uid: tutorials/first-mvc-app/adding-controller
1212

1313
[!INCLUDE[](~/includes/not-latest-version.md)]
1414

15-
By [Rick Anderson](https://twitter.com/RickAndMSFT)
16-
17-
:::moniker range=">= aspnetcore-9.0"
15+
:::moniker range=">= aspnetcore-10.0"
1816

1917
The Model-View-Controller (MVC) architectural pattern separates an app into three main components: **M**odel, **V**iew, and **C**ontroller. The MVC pattern helps you create apps that are more testable and easier to update than traditional monolithic apps.
2018

@@ -44,25 +42,25 @@ These concepts are introduced and demonstrated in this tutorial series while bui
4442

4543
In **Solution Explorer**, right-click **Controllers > Add > Controller**.
4644

47-
![Solution Explorer, right click Controllers > Add > Controller](~/tutorials/first-mvc-app/adding-controller/_static/9/add-controller-VS22-17.11.0.png)
45+
:::image type="content" source="~/tutorials/first-mvc-app/adding-controller/media/add-controller.png" alt-text="Solution Explorer, right click Controllers > Add > Controller.":::
4846

4947
In the **Add New Scaffolded Item** dialog box, select **MVC Controller - Empty** > **Add**.
5048

51-
![Add MVC controller](~/tutorials/first-mvc-app/adding-controller/_static/9/add-scaffolded-item-controller-VS22-17.11.0.png)
49+
:::image type="content" source="~/tutorials/first-mvc-app/adding-controller/media/add-new-scaffolded-item.png" alt-text="Add MVC controller.":::
5250

5351
In the **Add New Item - MvcMovie** dialog, enter *`HelloWorldController.cs`* and select **Add**.
5452

5553
# [Visual Studio Code](#tab/visual-studio-code)
5654

5755
Select the **EXPLORER** icon and then control-click (right-click) **Controllers > New File** and name the new file `HelloWorldController.cs`.
5856

59-
![Contextual menu](~/tutorials/first-mvc-app-xplat/adding-controller/_static/new_fileVSC1.51.png)
57+
:::image type="content" source="~/tutorials/first-mvc-app-xplat/adding-controller/_static/new_fileVSC1.51.png" alt-text="Contextual menu.":::
6058

6159
---
6260

6361
Replace the contents of `Controllers/HelloWorldController.cs` with the following code:
6462

65-
[!code-csharp[](~/tutorials/first-mvc-app/start-mvc/sample/mvcmovie90/Controllers/HelloWorldController.cs?name=snippet_First)]
63+
[!code-csharp[](~/tutorials/first-mvc-app/start-mvc/sample/mvcmovie10/Controllers/HelloWorldController.cs?name=snippet_First)]
6664

6765
Every `public` method in a controller is callable as an HTTP endpoint. In the sample above, both methods return a string. Note the comments preceding each method.
6866

@@ -82,15 +80,15 @@ Run the app without the debugger by pressing <kbd>Ctrl</kbd>+<kbd>F5</kbd>.
8280

8381
Append `/HelloWorld` to the path in the address bar. The `Index` method returns a string.
8482

85-
![Browser window showing an app response of This is my default action](~/tutorials/first-mvc-app/adding-controller/_static/9/hello1.png)
83+
:::image type="content" source="~/tutorials/first-mvc-app/adding-controller/_static/9/hello1.png" alt-text="Browser window showing an app response of This is my default action.":::
8684

8785
MVC invokes controller classes, and the action methods within them, depending on the incoming URL. The default [URL routing logic](xref:mvc/controllers/routing) used by MVC, uses a format like this to determine what code to invoke:
8886

8987
`/[Controller]/[ActionName]/[Parameters]`
9088

9189
The routing format is set in the `Program.cs` file.
9290

93-
[!code-csharp[](~/tutorials/first-mvc-app/start-mvc/sample/MvcMovie90/Program.cs?name=snippet_MapControllerRoute&highlight=3)]
91+
[!code-csharp[](~/tutorials/first-mvc-app/start-mvc/sample/MvcMovie10/Program.cs?name=snippet_MapControllerRoute&highlight=3)]
9492

9593
When you browse to the app and don't supply any URL segments, it defaults to the "Home" controller and the "Index" method specified in the template line highlighted above. In the preceding URL segments:
9694

@@ -102,13 +100,13 @@ Browse to: `https://localhost:{PORT}/HelloWorld/Welcome`. Replace `{PORT}` with
102100

103101
The `Welcome` method runs and returns the string `This is the Welcome action method...`. For this URL, the controller is `HelloWorld` and `Welcome` is the action method. You haven't used the `[Parameters]` part of the URL yet.
104102

105-
![Browser window showing an application response of This is the Welcome action method](~/tutorials/first-mvc-app/adding-controller/_static/9/welcome.png)
103+
:::image type="content" source="~/tutorials/first-mvc-app/adding-controller/_static/9/welcome.png" alt-text="Browser window showing an application response of This is the Welcome action method.":::
106104

107105
Modify the code to pass some parameter information from the URL to the controller. For example, `/HelloWorld/Welcome?name=Rick&numtimes=4`.
108106

109107
Change the `Welcome` method to include two parameters as shown in the following code.
110108

111-
[!code-csharp[](~/tutorials/first-mvc-app/start-mvc/sample/mvcmovie90/Controllers/HelloWorldController.cs?name=snippet_Second)]
109+
[!code-csharp[](~/tutorials/first-mvc-app/start-mvc/sample/mvcmovie10/Controllers/HelloWorldController.cs?name=snippet_Second)]
112110

113111
The preceding code:
114112

@@ -120,7 +118,7 @@ Run the app and browse to: `https://localhost:{PORT}/HelloWorld/Welcome?name=Ric
120118

121119
Try different values for `name` and `numtimes` in the URL. The MVC [model binding](xref:mvc/models/model-binding) system automatically maps the named parameters from the query string to parameters in the method. See [Model Binding](xref:mvc/models/model-binding) for more information.
122120

123-
![Browser window showing an application response of Hello Rick, NumTimes is\: 4](~/tutorials/first-mvc-app/adding-controller/_static/9/rick4.png)
121+
:::image type="content" source="~/tutorials/first-mvc-app/adding-controller/_static/9/rick4.png" alt-text="Browser window showing an application response of Hello Rick, NumTimes is 4.":::
124122

125123
In the previous image:
126124

@@ -131,7 +129,7 @@ In the previous image:
131129

132130
Replace the `Welcome` method with the following code:
133131

134-
[!code-csharp[](~/tutorials/first-mvc-app/start-mvc/sample/MvcMovie90/Controllers/HelloWorldController.cs?name=snippet_Third)]
132+
[!code-csharp[](~/tutorials/first-mvc-app/start-mvc/sample/MvcMovie10/Controllers/HelloWorldController.cs?name=snippet_Third)]
135133

136134
Run the app and enter the following URL: `https://localhost:{PORT}/HelloWorld/Welcome/3?name=Rick`
137135

@@ -141,7 +139,7 @@ In the preceding URL:
141139
* The `Welcome` method contains a parameter `id` that matched the URL template in the `MapControllerRoute` method.
142140
* The trailing `?` starts the [query string](https://wikipedia.org/wiki/Query_string).
143141

144-
[!code-csharp[](~/tutorials/first-mvc-app/start-mvc/sample/MvcMovie90/Program.cs?name=snippet_MapControllerRoute&highlight=3)]
142+
[!code-csharp[](~/tutorials/first-mvc-app/start-mvc/sample/MvcMovie10/Program.cs?name=snippet_MapControllerRoute&highlight=3)]
145143

146144
In the preceding example:
147145

@@ -155,6 +153,8 @@ In the preceding example:
155153
156154
:::moniker-end
157155

156+
[!INCLUDE[](~/tutorials/first-mvc-app/adding-controller/includes/adding-controller9.md)]
157+
158158
[!INCLUDE[](~/tutorials/first-mvc-app/adding-controller/includes/adding-controller8.md)]
159159

160160
[!INCLUDE[](~/tutorials/first-mvc-app/adding-controller/includes/adding-controller7.md)]

0 commit comments

Comments
 (0)