包括存全局变量、权限判断等基本功能 /**/ /// <summary>/// 页面基类/// </summary> public class PageBase:System.Web.UI.Page ... { public PageBase() ...{ } private Globals siteGlobals=new Globals(); protected virtual void Page_Load(object sender, EventArgs e) ...{ CheckUserInfo(); } 属性#region 属性 /**//// <summary> /// 应用程序路径 /// </summary> public string AppPath ...{ get ...{ return Request.ApplicationPath + "/"; } } /**//// <summary> /// 用户信息 /// </summary> public UserInfo MyInfo ...{ get ...{ //检查Cache if (HttpContext.Current.Cache["CurUser"] != null) return (UserInfo)HttpContext.Current.Cache["CurUser"]; //检查Session if (HttpContext.Current.Session["CurUser"] != null) ...{ return (UserInfo)HttpContext.Current.Session["CurUser"]; } //检查Cookie if (Request.Cookies["UserCode"] != null) ...{ //用户用Cookie登陆 HttpContext.Current.Session["CurUser"] = UserInfo.Get(Request.Cookies["UserCode"].Value); //Response.Cookies["UserInfo"]; return (UserInfo)HttpContext.Current.Session["CurUser"]; } return null; } } public Globals SiteGlobals ...{ get ...{ if (siteGlobals != null) return siteGlobals; else return null; } } #endregion /**//// <summary> /// 判断是否具该系统权限且是否登录 /// </summary> public void CheckUserInfo() ...{ if (MyInfo != null) ...{ if (MyInfo.SysType != 2 && MyInfo.SysType != 0) ...{ Response.Redirect(AppPath + "ErrorPage.Aspx?ErrorMsg=您没有权限登录该系统!", true); } } else ...{ Response.Redirect(AppPath + "Main/Login.aspx", true); } } protected override void OnInit(EventArgs e) ...{ if (!SiteGlobals.SiteOpenFlag) Response.Redirect(AppPath + "ErrorPage.Aspx?ErrorMsg=网站被关闭,暂时不能访问!", true); this.Load+=new EventHandler(this.Page_Load); base.OnInit(e); } protected override void OnUnload(EventArgs e) ...{ base.OnUnload(e); }}