Skip to content

Commit 8cbebff

Browse files
authored
Merge pull request #34364 from dotnet/main
2 parents 602121f + e203aa3 commit 8cbebff

File tree

3 files changed

+18
-27
lines changed

3 files changed

+18
-27
lines changed

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,19 +215,15 @@ Example:
215215

216216
Configuration is used to facilitate supplying dedicated key vaults and secret names based on the app's environmental configuration files. For example, you can supply different configuration values for `appsettings.Development.json` in development, `appsettings.Staging.json` when staging, and `appsettings.Production.json` for the production deployment. For more information, see <xref:blazor/fundamentals/configuration>.
217217

218-
## Redirect to the home page on sign out
218+
## Redirect to the home page on logout
219219

220-
When a user navigates around the app, the `LogInOrOut` component (`Layout/LogInOrOut.razor`) sets a hidden field for the return URL (`ReturnUrl`) to the value of the current URL (`currentURL`). When the user signs out of the app, the identity provider returns them to the page from which they signed out.
220+
The `LogInOrOut` component (`Layout/LogInOrOut.razor`) sets a hidden field for the return URL (`ReturnUrl`) to the current URL (`currentURL`). When the user signs out of the app, the identity provider returns the user to the page from which they logged out. If the user logs out from a secure page, they're returned to the same secure page and sent back through the authentication process. This authentication flow is reasonable when users need to change accounts regularly.
221221

222-
If the user signs out from a secure page, they're returned back to the same secure page after signing out only to be sent back through the authentication process. This behavior is fine when users need to switch accounts frequently. However, a alternative app specification may call for the user to be returned to the app's home page or some other page after signing out. The following example shows how to set the app's home page as the return URL for sign-out operations.
223-
224-
The important changes to the `LogInOrOut` component are demonstrated in the following example. There's no need to provide a hidden field for the `ReturnUrl` set to the home page at `/` because that's the default path. <xref:System.IDisposable> is no longer implemented. The <xref:Microsoft.AspNetCore.Components.NavigationManager> is no longer injected. The entire `@code` block is removed.
222+
Alternatively, use the following `LogInOrOut` component, which doesn't supply a return URL when logging out.
225223

226224
`Layout/LogInOrOut.razor`:
227225

228226
```razor
229-
@using Microsoft.AspNetCore.Authorization
230-
231227
<div class="nav-item px-3">
232228
<AuthorizeView>
233229
<Authorized>

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -620,19 +620,15 @@ The <xref:Microsoft.AspNetCore.Builder.AuthorizationEndpointConventionBuilderExt
620620

621621
:::zone-end
622622

623-
## Redirect to the home page on signout
623+
## Redirect to the home page on logout
624624

625-
When a user navigates around the app, the `LogInOrOut` component (`Layout/LogInOrOut.razor`) sets a hidden field for the return URL (`ReturnUrl`) to the value of the current URL (`currentURL`). When the user signs out of the app, the identity provider returns them to the page from which they signed out.
625+
The `LogInOrOut` component (`Layout/LogInOrOut.razor`) sets a hidden field for the return URL (`ReturnUrl`) to the current URL (`currentURL`). When the user signs out of the app, the identity provider returns the user to the page from which they logged out. If the user logs out from a secure page, they're returned to the same secure page and sent back through the authentication process. This authentication flow is reasonable when users need to change accounts regularly.
626626

627-
If the user signs out from a secure page, they're returned back to the same secure page after signing out only to be sent back through the authentication process. This behavior is fine when users need to switch accounts frequently. However, a alternative app specification may call for the user to be returned to the app's home page or some other page after signout. The following example shows how to set the app's home page as the return URL for signout operations.
628-
629-
The important changes to the `LogInOrOut` component are demonstrated in the following example. There's no need to provide a hidden field for the `ReturnUrl` set to the home page at `/` because that's the default path. <xref:System.IDisposable> is no longer implemented. The <xref:Microsoft.AspNetCore.Components.NavigationManager> is no longer injected. The entire `@code` block is removed.
627+
Alternatively, use the following `LogInOrOut` component, which doesn't supply a return URL when logging out.
630628

631629
`Layout/LogInOrOut.razor`:
632630

633631
```razor
634-
@using Microsoft.AspNetCore.Authorization
635-
636632
<div class="nav-item px-3">
637633
<AuthorizeView>
638634
<Authorized>

aspnetcore/fundamentals/startup.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn how the Startup class in ASP.NET Core configures services and
55
monikerRange: '>= aspnetcore-3.1'
66
ms.author: wpickett
77
ms.custom: mvc
8-
ms.date: 5/5/2023
8+
ms.date: 12/12/2024
99
uid: fundamentals/startup
1010
---
1111
# App startup in ASP.NET Core
@@ -20,18 +20,17 @@ ASP.NET Core apps created with the web templates contain the application startup
2020

2121
For Blazor startup guidance, which adds to or supersedes the guidance in this article, see <xref:blazor/fundamentals/startup>.
2222

23-
The following app startup code supports:
23+
The following app startup code supports several app types:
2424

25+
* [Blazor Web Apps](xref:blazor/index)
2526
* [Razor Pages](xref:tutorials/razor-pages/razor-pages-start)
2627
* [MVC controllers with views](xref:tutorials/first-mvc-app/start-mvc)
2728
* [Web API with controllers](xref:tutorials/first-web-api)
2829
* [Minimal APIs](xref:tutorials/min-web-api)
2930

30-
[!code-csharp[](~/fundamentals/startup/6.0_samples/WebAll/Program.cs?name=snippet)]
31+
[!code-csharp[](~/fundamentals/startup/9.0_samples/WebAll/Program.cs?name=snippet)]
3132

32-
Apps using [EventSource](/dotnet/api/system.diagnostics.tracing.eventsource) can measure the startup time to understand and optimize startup performance. The [`ServerReady`](https://source.dot.net/#Microsoft.AspNetCore.Hosting/Internal/HostingEventSource.cs,76) event in <xref:Microsoft.AspNetCore.Hosting?displayProperty=fullName> represents the point where the server is ready to respond to requests.
33-
34-
For more information on application startup, see <xref:fundamentals/index>.
33+
Apps that use <xref:System.Diagnostics.Tracing.EventSource> can measure the startup time to understand and optimize startup performance. The [`ServerReady`](https://source.dot.net/#Microsoft.AspNetCore.Hosting/Internal/HostingEventSource.cs,76) event in <xref:Microsoft.AspNetCore.Hosting?displayProperty=fullName> represents the point where the server is ready to respond to requests.
3534

3635
<a name="IStartupFilter"></a>
3736

@@ -42,19 +41,19 @@ Use <xref:Microsoft.AspNetCore.Hosting.IStartupFilter>:
4241
* To configure middleware at the beginning or end of an app's middleware pipeline without an explicit call to `Use{Middleware}`. Use `IStartupFilter` to add defaults to the beginning of the pipeline without explicitly registering the default middleware. `IStartupFilter` allows a different component to call `Use{Middleware}` on behalf of the app author.
4342
* To create a pipeline of `Configure` methods. [IStartupFilter.Configure](xref:Microsoft.AspNetCore.Hosting.IStartupFilter.Configure%2A) can set a middleware to run before or after middleware added by libraries.
4443

45-
`IStartupFilter` implements <xref:Microsoft.AspNetCore.Hosting.StartupBase.Configure%2A>, which receives and returns an `Action<IApplicationBuilder>`. An <xref:Microsoft.AspNetCore.Builder.IApplicationBuilder> defines a class to configure an app's request pipeline. For more information, see [Create a middleware pipeline with IApplicationBuilder](xref:fundamentals/middleware/index#create-a-middleware-pipeline-with-iapplicationbuilder).
44+
An `IStartupFilter` implementation implements <xref:Microsoft.AspNetCore.Hosting.StartupBase.Configure%2A>, which receives and returns an `Action<IApplicationBuilder>`. An <xref:Microsoft.AspNetCore.Builder.IApplicationBuilder> defines a class to configure an app's request pipeline. For more information, see [Create a middleware pipeline with IApplicationBuilder](xref:fundamentals/middleware/index#create-a-middleware-pipeline-with-iapplicationbuilder).
4645

47-
Each `IStartupFilter` can add one or more middlewares in the request pipeline. The filters are invoked in the order they were added to the service container. Filters may add middleware before or after passing control to the next filter, thus they append to the beginning or end of the app pipeline.
46+
Each `IStartupFilter` implementation can add one or more middlewares in the request pipeline. The filters are invoked in the order they were added to the service container. Filters can add middleware before or after passing control to the next filter, thus they append to the beginning or end of the app pipeline.
4847

4948
The following example demonstrates how to register a middleware with `IStartupFilter`. The `RequestSetOptionsMiddleware` middleware sets an options value from a query string parameter:
5049

5150
[!code-csharp[](~/fundamentals/startup/7/WebStartup/Middleware/RequestSetOptionsMiddleware.cs?name=snippet1)]
5251

5352
The `RequestSetOptionsMiddleware` is configured in the `RequestSetOptionsStartupFilter` class:
5453

55-
[!code-csharp[](~/fundamentals/startup/7/WebStartup/Middleware/RequestSetOptionsStartupFilter.cs?name=snippet1?name=snippet1&highlight=7)]
54+
[!code-csharp[](~/fundamentals/startup/7/WebStartup/Middleware/RequestSetOptionsStartupFilter.cs?name=snippet1&highlight=7)]
5655

57-
The `IStartupFilter` is registered in `Program.cs`:
56+
The `IStartupFilter` implementation is registered in `Program.cs`:
5857

5958
[!code-csharp[](~/fundamentals/startup/7/WebStartup/Program.cs?highlight=6-7)]
6059

@@ -64,13 +63,13 @@ When a query string parameter for `option` is provided, the middleware processes
6463

6564
Middleware execution order is set by the order of `IStartupFilter` registrations:
6665

67-
* Multiple `IStartupFilter` implementations may interact with the same objects. If ordering is important, order their `IStartupFilter` service registrations to match the order that their middlewares should run.
68-
* Libraries may add middleware with one or more `IStartupFilter` implementations that run before or after other app middleware registered with `IStartupFilter`. To invoke an `IStartupFilter` middleware before a middleware added by a library's `IStartupFilter`:
66+
* Multiple `IStartupFilter` implementations might interact with the same objects. If ordering is important, order their `IStartupFilter` service registrations to match the order that their middlewares should run.
67+
* Libraries can add middleware with one or more `IStartupFilter` implementations that run before or after other app middleware registered with `IStartupFilter`. To invoke an `IStartupFilter` middleware before a middleware added by a library's `IStartupFilter`:
6968

7069
* Position the service registration before the library is added to the service container.
7170
* To invoke afterward, position the service registration after the library is added.
7271

73-
Note: You can't extend the ASP.NET Core app when you override `Configure`. For more informaton, see [this GitHub issue](https://github.com/dotnet/aspnetcore/issues/45372).
72+
You can't extend the ASP.NET Core app when you override `Configure`. For more information, see [this GitHub issue](https://github.com/dotnet/aspnetcore/issues/45372).
7473

7574
## Add configuration at startup from an external assembly
7675

0 commit comments

Comments
 (0)