public async Task <IActionResult> Login(Login model) { Login user = _userData.DoLogin(model.UserName, model.Password); string rUrl = HttpContext.Request.Path; string Role = "User"; rUrl = Url.ToString(); if (user.UserName != "" && user.UType == UserType.User) { var claims = new List <Claim> { new Claim(ClaimTypes.Name, user.UserName), new Claim(ClaimTypes.Sid, user.UserId.ToString()), new Claim(ClaimTypes.Role, Role) }; var userIdentity = new ClaimsIdentity(claims, "login"); ClaimsPrincipal principal = new ClaimsPrincipal(userIdentity); //await HttpContext.Authentication.SignInAsync("CookieAuthentication", principal); await HttpContext.SignInAsync(principal); return(RedirectToAction("Index", model.RetUrl)); } return(View()); }