@page "/logout"
@using Microsoft.AspNetCore.Authentication
@using Microsoft.AspNetCore.Authentication.Cookies
@inject IHttpContextAccessor HttpContextAccessor;
@inject NavigationManager Navigation;
How did you get here?
@code { protected override async Task OnInitializedAsync() { var context = HttpContextAccessor.HttpContext; if (context is null) throw new ArgumentException("HttpContext"); await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); Navigation.NavigateTo("/", true); } }