日期:2014-05-20 浏览次数:20410 次
public class PageBase:System.Web.UI.Page { public int PermissionID = -1;//默认-1为无限制,可以在不同页面继承里来控制不同页面的权限 /// <summary> /// 构造函数 /// </summary> public PageBase() { this.Load += new EventHandler(PageBase_Load); } protected override void OnInit(EventArgs e) { base.OnInit(e); this.Load += new System.EventHandler(PageBase_Load); this.Error += new System.EventHandler(PageBase_Error); } //错误处理 protected void PageBase_Error(object sender, System.EventArgs e) { string errMsg; Exception currentError = Server.GetLastError(); errMsg = ""; errMsg +="错误地址: " + Request.Url.ToString() + "<br/>" + "错误信息: " + currentError.Message.ToString() + "<hr/>" + "<b>Stack Trace:</b><br/>" + currentError.ToString(); Common.saveLogFiles("页面错误", errMsg);//把错误信息保存为文本文件 Server.ClearError(); } private void PageBase_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request.Cookies["UserInfo"] == null) { Response.Write("<script language=\"javascript\">window.top.location.href=\"login.aspx\";</script>"); Response.End(); } } } }