重写页面基类(判断丢失Session)-保证不丢失VIEWSATE-完美解决方案

来源:互联网 发布:弹跳法术升级数据 编辑:程序博客网 时间:2024/05/22 15:52
/// <summary>/// PageBaseNew 的摘要说明/// </summary>public class PageBaseNew:System.Web.UI.Page    { public PageBaseNew() {        this.Load += new System.EventHandler(PageBaseNew_Load); }    private void PageBaseNew_Load(object sender, System.EventArgs e)     {                if (Session["userid"] == null)        {            Response.Write("<script language = javascript>window.parent.opener=null;window.open('" + BaseUrl + "Login.aspx','_top')</script>");//考虑到框架问题         }             }    public string BaseUrl    {        get        {            string strBaseUrl = "";            strBaseUrl += "http://" + HttpContext.Current.Request.Url.Host;            if (HttpContext.Current.Request.Url.Port.ToString() != "80")            {                strBaseUrl += ":" + HttpContext.Current.Request.Url.Port.ToString();            }            strBaseUrl += HttpContext.Current.Request.ApplicationPath;            return strBaseUrl + "/";        }    }}