public ActionResult LogOff() { var userId = User.Identity.GetUserId(); ChatHub.OfflineUser(userId); AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); return(RedirectToAction("Index", "Home")); }
public ActionResult Logout() { int userId = int.Parse(User.Identity.Name); new AppService().RemoveAllUserConnections(userId); ChatHub.OfflineUser(userId); FormsAuthentication.SignOut(); return(RedirectToAction("Login")); }
protected void LoggingOut(object sender, EventArgs e) { int userId = int.Parse(HttpContext.Current.User.Identity.Name); string query = "Delete from [Connections] where UserId = @id"; cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@id", userId); con.Open(); cmd.ExecuteNonQuery(); con.Close(); ChatHub.OfflineUser(userId); Session.Clear(); Session.Abandon(); FormsAuthentication.SignOut(); }