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/blazor/security/blazor-web-app-with-entra.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
1
---
2
2
title: Secure an ASP.NET Core Blazor Web App with Microsoft Entra ID
3
+
ai-usage: ai-assisted
3
4
author: guardrex
4
5
description: Learn how to secure a Blazor Web App with Microsoft Entra ID.
5
6
monikerRange: '>= aspnetcore-9.0'
@@ -1150,6 +1151,12 @@ Alternatively, use the following `LogInOrOut` component, which doesn't supply a
1150
1151
1151
1152
Formoreinformationonhowthisappsecuresitsweatherdata, see [SecuredatainBlazorWebAppswithInteractiveAutorendering](xref:blazor/security/index#secure-data-in-blazor-web-apps-with-interactive-auto-rendering).
For more information, see the [Duende Access Token Management documentation for Blazor](https://docs.duendesoftware.com/accesstokenmanagement/blazor-server/).
1490
1491
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:
* 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>.
By [Rick Anderson](https://twitter.com/RickAndMSFT)
16
-
17
-
:::moniker range=">= aspnetcore-9.0"
15
+
:::moniker range=">= aspnetcore-10.0"
18
16
19
17
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.
20
18
@@ -44,25 +42,25 @@ These concepts are introduced and demonstrated in this tutorial series while bui
44
42
45
43
In **Solution Explorer**, right-click **Controllers > Add > Controller**.
46
44
47
-

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.
68
66
@@ -82,15 +80,15 @@ Run the app without the debugger by pressing <kbd>Ctrl</kbd>+<kbd>F5</kbd>.
82
80
83
81
Append `/HelloWorld` to the path in the address bar. The `Index` method returns a string.
84
82
85
-

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.":::
86
84
87
85
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:
88
86
89
87
`/[Controller]/[ActionName]/[Parameters]`
90
88
91
89
The routing format is set in the `Program.cs` file.
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:
96
94
@@ -102,13 +100,13 @@ Browse to: `https://localhost:{PORT}/HelloWorld/Welcome`. Replace `{PORT}` with
102
100
103
101
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.
104
102
105
-

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.":::
106
104
107
105
Modify the code to pass some parameter information from the URL to the controller. For example, `/HelloWorld/Welcome?name=Rick&numtimes=4`.
108
106
109
107
Change the `Welcome` method to include two parameters as shown in the following code.
@@ -120,7 +118,7 @@ Run the app and browse to: `https://localhost:{PORT}/HelloWorld/Welcome?name=Ric
120
118
121
119
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.
122
120
123
-

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.":::
124
122
125
123
In the previous image:
126
124
@@ -131,7 +129,7 @@ In the previous image:
131
129
132
130
Replace the `Welcome` method with the following code:
0 commit comments