public ActionResult Login(LoginModel model) { string viewName = "Index"; if (ModelState.IsValid) { // Check the user's credentials against the database AccountConnection accountConnection = new AccountConnection(); SignInRequest request = new SignInRequest() { Username = model.Username, Password = model.Password }; SignInResponse response = accountConnection.SignIn(request); if (response.UserId != -1) { // Redirect the user to home and store the user id as a session variable. Helps for account tracking. viewName = "Home"; Session["UserId"] = response.UserId; Session["UserType"] = response.UserType; Session["Username"] = model.Username; } } return(RedirectToAction(viewName)); }