I want to fix an issue where the sign-in user will never see the login page again unless he/she logout. How can i do it in asp.net core 2.2 identity razor page???
I want to fix an issue where the sign-in user will never see the login page again unless he/she logout. How can i do it in asp.net core 2.2 identity razor page???
To achieve above requirement, you can create and use a custom Razor Page filter to check request path and current user login status, like blow.
public Task OnPageHandlerSelectionAsync(PageHandlerSelectedContext context)
{
if (context.HttpContext.Request.Path == "/Identity/Account/Login"&& context.HttpContext.User.Identity.IsAuthenticated)
{
//redirect to index page
context.HttpContext.Response.Redirect("/");
}
return Task.CompletedTask;
}