This is suddenly happened after I rebooted my notebook for Windows update!, it should be routes to /user/login
HomeController --> looks like it doesn't arrive here!
public IActionResult Index(string ReturnUrl = null)
{
if (!Url.IsLocalUrl(ReturnUrl))
{
return RedirectToAction("Login", "User");
}
if (!string.IsNullOrEmpty(ReturnUrl))
{
Redirect(ReturnUrl);
}
return View();
}
UserController
[HttpGet]
[Route("/User/Login")]
[AllowAnonymous]
public IActionResult Login(string ReturnUrl = null) --> looks like it doesn't arrive here!
{
Views.User.Login login = new Views.User.Login();
login.ReturnUrl = (ReturnUrl == null ? "": ReturnUrl);
return View(login);
}
I didn't set IsPersistent = true,
public interface IUserManager
{
Task SignIn(HttpContext httpContext, CookieUserItem user, bool isPersistent = false);
Task SignOut(HttpContext httpContext);
}
public async Task SignIn(HttpContext httpContext, CookieUserItem user, bool isPersistent = false)
{
string authenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme;
// Generate Claims from DbEntity
var claims = GetUserClaims(user);
// Add Additional Claims from the Context
// which might be useful
// claims.Add(httpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Name));
ClaimsIdentity claimsIdentity = new ClaimsIdentity(claims, authenticationScheme);
ClaimsPrincipal claimsPrincipal = new ClaimsPrincipal(claimsIdentity);
var authProperties = new AuthenticationProperties
{
// AllowRefresh = <bool>,
// Refreshing the authentication session should be allowed.
// ExpiresUtc = DateTimeOffset.UtcNow.AddMinutes(10),
// The time at which the authentication ticket expires. A
// value set here overrides the ExpireTimeSpan option of
// CookieAuthenticationOptions set with AddCookie.
// IsPersistent = true,
// Whether the authentication session is persisted across
// multiple requests. Required when setting the
// ExpireTimeSpan option of CookieAuthenticationOptions
// set with AddCookie. Also required when setting
// ExpiresUtc.
// IssuedUtc = <DateTimeOffset>,
// The time at which the authentication ticket was issued.
// RedirectUri = "~/Account/Index"
// The full path or absolute URI to be used as an http
// redirect response value.
};
await httpContext.SignInAsync(authenticationScheme, claimsPrincipal, authProperties);
}