public IActionResult LoginUser(UserDetail ud) { UserMethod um = new UserMethod(); List <UserDetail> users = new List <UserDetail>(); string error = ""; users = um.GetUsers(out error); UserDetail currentUser = users.Find(user => user.Username == ud.Username); if (currentUser != null) { string usr = JsonConvert.SerializeObject(currentUser); HttpContext.Session.SetString("currentuser", usr); return(View("UserSettings", currentUser)); } else { ViewBag.error = "Inloggningsuppgifterna stämmer inte."; return(View()); } }