Blazor中使用RedirectToLogin.razor重定向出现错误求助
Blazor 授权跳转登录页面时出现错误,请求帮助
App.razor 代码
@using DorpshuisManager.Areas.Identity.Components <CascadingAuthenticationState> <Router AppAssembly="@typeof(App).Assembly"> <Found Context="routeData"> <AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"> <NotAuthorized> @if (!context.User.Identity.IsAuthenticated) { <RedirectToLogin ReturnUrl="@NavigationManager.ToBaseRelativePath(NavigationManager.Uri)" /> } else { <p role="alert">Sorry, you're not authorized to view this page.</p> } </NotAuthorized> </AuthorizeRouteView> <FocusOnNavigate RouteData="@routeData" Selector="h1" /> </Found> <NotFound> <PageTitle>Not found</PageTitle> <LayoutView Layout="@typeof(MainLayout)"> <div class="d-flex vw-100 vh-100 align-items-center justify-content-center text-center"> <div> <iconify-icon icon="tabler:face-id-error" style="color: black;" width="100" height="100"></iconify-icon> <h1>Pagina niet gevonden ...</h1> <a href="/"> <button class="btn btn-primary mt-3 btn-rounded py-3 px-4">Ga naar home pagina</button> </a> </div> </div> </LayoutView> </NotFound> </Router> </CascadingAuthenticationState>
RedirectToLogin.razor 代码
@code { [Parameter] public string ReturnUrl { get; set; } protected override async Task OnInitializedAsync() { ReturnUrl = "~/" + ReturnUrl; NavigationManager.NavigateTo("Identity/Account/Login?returnUrl=" + ReturnUrl, true); await base.OnInitializedAsync(); } }
运行代码时出现错误(截图:
)。我已在谷歌、Stack Overflow搜索解决方案,尝试过Blazor组件跳转至Razor页面的相关方案,但均无法解决问题,恳请帮忙排查。
内容的提问来源于stack exchange,提问作者Jeremy
相关产品推荐
相关产品推荐

