I have the following code in LogOut razor page.
public async Task OnPostAsync()
{
await loginManager.SignOutAsync();
RedirectToPage("/Identity/Login");
}
But it is not redirecting to login page as expected. It still shows LogOut page.
If I use Response.Redirect() instead of RedirectToPage() then it works.
I am using Preview 3 of ASP.NET Core 3.
The RedirectToPage()
method is generating a RedirectToPageResult
that you forgot to actually return
from your action.
Try this instead:
public async Task<IActionResult> OnPostAsync()
{
await loginManager.SignOutAsync();
return RedirectToPage("/Identity/Login");
}