diff --git a/AspNetCore/Blazor/AdHocReporting.BlazorWasm/Client/EqDemo.BlazorWasm.AdhocReporting.Client.csproj b/AspNetCore/Blazor/AdHocReporting.BlazorWasm/Client/EqDemo.BlazorWasm.AdhocReporting.Client.csproj index 757d9614..8366b706 100644 --- a/AspNetCore/Blazor/AdHocReporting.BlazorWasm/Client/EqDemo.BlazorWasm.AdhocReporting.Client.csproj +++ b/AspNetCore/Blazor/AdHocReporting.BlazorWasm/Client/EqDemo.BlazorWasm.AdhocReporting.Client.csproj @@ -1,18 +1,18 @@  - net6.0 + net8.0 EqDemo.Client enable enable - - - - - + + + + + diff --git a/AspNetCore/Blazor/AdHocReporting.BlazorWasm/Client/Pages/Authentication.razor b/AspNetCore/Blazor/AdHocReporting.BlazorWasm/Client/Pages/Authentication.razor index 6c743567..8c443cf6 100644 --- a/AspNetCore/Blazor/AdHocReporting.BlazorWasm/Client/Pages/Authentication.razor +++ b/AspNetCore/Blazor/AdHocReporting.BlazorWasm/Client/Pages/Authentication.razor @@ -1,7 +1,25 @@ @page "/authentication/{action}" -@using Microsoft.AspNetCore.Components.WebAssembly.Authentication - + +@inject NavigationManager Navigation @code{ [Parameter] public string? Action { get; set; } + + protected override void OnInitialized() + { + var returnUrl = Uri.EscapeDataString("/"); + var redirectUrl = Action?.ToLower() switch + { + "login" => $"Identity/Account/Login?returnUrl={returnUrl}", + "register" => $"Identity/Account/Register?returnUrl={returnUrl}", + "logout" => "Identity/Account/LogOut", + "profile" => "Identity/Account/Manage", + _ => "" + }; + + if (!string.IsNullOrEmpty(redirectUrl)) + { + Navigation.NavigateTo(redirectUrl, forceLoad: true); + } + } } diff --git a/AspNetCore/Blazor/AdHocReporting.BlazorWasm/Client/Pages/Reports.razor b/AspNetCore/Blazor/AdHocReporting.BlazorWasm/Client/Pages/Reports.razor index ac5ce0a1..ecfd20cc 100644 --- a/AspNetCore/Blazor/AdHocReporting.BlazorWasm/Client/Pages/Reports.razor +++ b/AspNetCore/Blazor/AdHocReporting.BlazorWasm/Client/Pages/Reports.razor @@ -1,14 +1,11 @@ @page "/reports" @using Microsoft.AspNetCore.Authorization -@using Microsoft.AspNetCore.Components.WebAssembly.Authentication -@using Microsoft.AspNetCore.Components.WebAssembly.Authentication.Internal @attribute [Authorize] @implements IAsyncDisposable @inject IJSRuntime JSRuntime @inject NavigationManager NavigationManager @inject AuthenticationStateProvider AuthenticationStateProvider -@inject IAccessTokenProviderAccessor AccessTokenProviderAccessor