[Authorize] public ActionResult Logoff() {FormsAuthentication.SignOut(); Session.Abandon();return RedirectToAction("Index", "Home"); }
FormsAuthentication.SignOut(); this method is used for sign out from forms authentication.
protected void btnLogout_Click(object sender, EventArgs e){try{Response.Cache.SetCacheability(HttpCacheability.NoCache);Response.Cache.SetNoStore();Response.Cookies.Clear();Session.Abandon();//HttpContext.Current.Session["ownerpanel"] = null;//HttpContext.Current.Session.Abandon();FormsAuthentication.SignOut();FormsAuthentication.RedirectToLoginPage();}catch { }}
The FormsAuthentication.Signout() method is used to sign out from the forms authentication.