public ActionResult LogOff(int userID) { string ip = ""; if (ViewBag.IPAddress != null) { ip = ViewBag.IPAddress.StringSafe(); } UserType user = UserCache.GetFromCache(userID, ip); AccessModel model = new AccessModel(); UserType _user = new UserType(); if (user != null) { _user = new UserType { UserName = "******", UserID = -1, SessionStart = DateTime.Now }; } bool bRet = model.LogOff(user); if (bRet) { UserCache.RemoveFromCache(user.UserID, ""); UserCache.AddToCache(_user); } return(RedirectToAction("index", "home")); }