I used remember me in the form,Now I want to get the value of IsPersistent and put a code condition on one of the actions. I searched a lot but couldn't find anything, even the links below didn't help.
How to get is session IsPersistent on ASP.NET MVC?
How to get isPersistent (AuthenticationProperties)
Claims Code :
private void LoginByClaims(Guid userid, Guid roleid,bool remembr)
{
var claims = new List<Claim>()
{
new Claim(ClaimTypes.Name,userid.ToString()),
new Claim(ClaimTypes.NameIdentifier,roleid.ToString()),
};
var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
var principal = new ClaimsPrincipal(identity);
var properties = new AuthenticationProperties
{
IsPersistent = remembr
};
HttpContext.SignInAsync(principal, properties);
}
Action for condition :
public IActionResult Login()
{
if (User.Identity.Name == null)
{
return View();
}
return RedirectToAction("Dashboard", "Profile");
}
If the remember me check was done, will it go to one action, and if it was not checked, to another action?