public ActionResult Login(string username, string password) { ViewBag.Title = "Login"; if (string.IsNullOrEmpty(username) && string.IsNullOrEmpty(password)) { return(Login()); } ApiAccountController apiController = new ApiAccountController(); string token = apiController.Login(username, password); if (string.IsNullOrEmpty(token)) { Session.Remove("token"); return(View(new Person { Error = true, Username = username, Token = model.Token })); } else { Session["token"] = token; if (Session["redirect"] != null) { string redirect = Session["redirect"].ToString(); Session.Remove("redirect"); return(Redirect(redirect)); } else { return(RedirectToAction("Index", "Home")); } } }