Exemple #1
0
        public ActionResult LogOff()
        {
            long UserId = 0;

            if (Session["UserId"] != null)
            {
                UserId = long.Parse(Session["UserId"].ToString());
            }
            else
            {
                IPrincipal user         = HttpContext.User;
                IIdentity  userIdentity = user.Identity;

                FormsIdentity             id     = (FormsIdentity)user.Identity;
                FormsAuthenticationTicket ticket = id.Ticket;

                if (ticket != null)
                {
                    UserId = long.Parse(ticket.UserData);
                }
            }

            Metodos.Logout(UserId);
            Auditoria.RegistrarLogout();
            Session.Abandon();
            Session.RemoveAll();
            FormsAuthentication.SignOut();
            return(RedirectToAction("Index", "Home"));
        }