您的位置:首页 > 其它

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

2010-06-28 20:55 351 查看
/// <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 + "/";
        }
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐