Skip to content

Commit e203aa3

Browse files
authored
Improve the redirect on logout section (#34370)
1 parent 1d254df commit e203aa3

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
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>

0 commit comments

Comments
 (0)