public async Task <ActionResult> Register(BeSafeModels.User user) { if (ModelState.IsValid) { BeSafeEntities.User LogedinUser = UserBusinessLogic.UserValidation(user.UserName, user.Password).Result; if (LogedinUser == null) { var userEntity = mapUserModelToEntity.ConvertObject(user); userEntity.CreatedDate = DateTime.Now; LogedinUser = await UserBusinessLogic.AddUser(userEntity); } var claims = new List <Claim> { new Claim(ClaimTypes.Name, LogedinUser.UserName), new Claim(ClaimTypes.Sid, LogedinUser.ID.ToString()), new Claim(ClaimTypes.Email, LogedinUser.Email) }; var claimsIdentity = new ClaimsIdentity(claims, "Login"); await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity)); return(RedirectToAction("Index", "Admin")); } return(View(user)); }