📄 logout.cs
字号:
namespace PowerEasy.WebSite.Admin
{
using PowerEasy.Components;
using PowerEasy.Logging;
using PowerEasy.Model.UserManage;
using PowerEasy.UserManage;
using PowerEasy.Web.UI;
using System;
using System.Web;
using System.Web.Security;
using System.Web.UI.HtmlControls;
public class Logout : AdminPage
{
protected HtmlForm form1;
protected void Page_Load(object sender, EventArgs e)
{
if (PEContext.Current.Admin.Identity.IsAuthenticated)
{
LogInfo info = new LogInfo();
info.UserName = PEContext.Current.Admin.AdminName;
info.UserIP = PEContext.Current.UserHostAddress;
info.ScriptName = base.Request.RawUrl;
info.Timestamp = DateTime.Now;
info.PostString = "\r\nFORM: " + HttpContext.Current.Request.Form.ToString() + "\r\nQUERYSTRING: " + HttpContext.Current.Request.QueryString.ToString();
info.Source = "";
string name = FormsAuthentication.FormsCookieName + "AdminCookie";
string str2 = string.Empty;
if (HttpContext.Current.Request.Browser["supportsEmptyStringInCookieValue"] == "false")
{
str2 = "NoCookie";
}
HttpCookie cookie = new HttpCookie(name, str2);
cookie.HttpOnly = true;
cookie.Path = FormsAuthentication.FormsCookiePath;
cookie.Expires = new DateTime(0x7cf, 10, 12);
cookie.Secure = FormsAuthentication.RequireSSL;
if (FormsAuthentication.CookieDomain != null)
{
cookie.Domain = FormsAuthentication.CookieDomain;
}
HttpContext.Current.Response.Cookies.Remove(name);
HttpContext.Current.Response.Cookies.Add(cookie);
FormsAuthentication.SignOut();
AdministratorInfo administratorByAdminName = Administrators.GetAdministratorByAdminName(PEContext.Current.Admin.AdministratorInfo.AdminName);
administratorByAdminName.LastLogoutTime = new DateTime?(DateTime.Now);
Administrators.Update(administratorByAdminName);
info.Category = LogCategory.LogOut;
info.Message = "退出成功";
info.Title = info.UserName + " 退出成功";
info.Priority = LogPriority.Normal;
LogFactory.CreateLog().Add(info);
}
BasePage.ResponseRedirect("index.aspx");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -