adminheader.ascx.cs

来自「网上那个书店开发系统论文,需要的朋友可以下载参考哦」· CS 代码 · 共 66 行

CS
66
字号
namespace EMBookManage.Inc
{
	using System;
	using System.Data;
	using System.Drawing;
	using System.Web;
	using System.Web.UI.WebControls;
	using System.Web.UI.HtmlControls;
	using System.Web.Security;

	/// <summary>
	///		Header 的摘要说明。
	/// </summary>
	public partial class AdminHeader : System.Web.UI.UserControl
	{

		protected void Page_Load(object sender, System.EventArgs e)
		{
            BookManageSecurity.CheckAdminPermission();
			if(Request.IsAuthenticated)
			{
				btnLogout.Visible=true;
				lblLogin.Visible=false;
			}
			else if(!Request.IsAuthenticated)
			{
				lblLogin.Visible=true;
				btnLogout.Visible=false;
			}
		}
		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		///		设计器支持所需的方法 - 不要使用代码编辑器
		///		修改此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{

		}
		#endregion

		protected void btnLogout_Click(object sender, System.EventArgs e)
		{
			//退出form验证
			FormsAuthentication.SignOut();
			//清楚所有session
			Session.RemoveAll();
			//清除登陆cookie
			HttpCookie cookie=Request.Cookies[FormsAuthentication.FormsCookieName];
			cookie.Expires=DateTime.Now;
			Response.Cookies.Add(cookie);
			//重定向到登录页
			Response.Redirect("~/login.aspx");
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?