Page_Load事件中加入
 Server.Execute("check.aspx");
check.aspx内容:
 protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["flag"] != "true" || Session["type"] != "teacher" || Session["name"] == null|| Session["id"]== null)
        {
            Response.Redirect("errow.aspx");
        }
             
    }
其他的窗体都是可以的,只有这一个永远报错

解决方案 »

  1.   

    if (Session["flag"] != "true" || Session["type"] != "teacher" || Session["name"] == null|| Session["id"]== null) 改为
    if (Session["id"]==null ||  Session["name"] == null || Session["flag"] != "true" || Session["type"] != "teacher" )
    试试
      

  2.   

    不管你的条件是否满足,但是肯定会定位到errow.aspx
      

  3.   

    先判断是不是 Null 再判断是什么值
      

  4.   

    如果这个页面是弹出窗口的话,
    Session是可能会丢失的
      

  5.   

    没太明白意思...try...
    if (Session["name"] == null || Session["id"] == null || Session["flag"]==null || Session["type"]==null || Session["flag"].ToString()!= "true" || Session["type"].ToString() != "teacher" )
                {
                    Response.Redirect("errow.aspx");
                }
      

  6.   

    我做了十几页面
    然后做了一个验证页面check.aspx
    我在每页的page_load事件中加入server.excute("check.aspx")
    其他的页面都可以实现验证权限功能
    只有这一个,无论你是否是合法用户他都会跳到错误的页面(errow.aspx)
      

  7.   

    TO:
    我做了十几页面
    然后做了一个验证页面check.aspx
    我在每页的page_load事件中加入server.excute("check.aspx")
    其他的页面都可以实现验证权限功能
    只有这一个,无论你是否是合法用户他都会跳到错误的页面(errow.aspx)你说的这种用法我以前也做过...
    但是你没有把错误说清楚,所以别人也没法帮你啊...
      

  8.   

    举个例子,问你一下..你的Session["flag"]是怎么用的?是Session["flag"]=true?
    还是Session["flag"]="true"?等等..
      

  9.   

    简单讲
    如果他成立就重定向到登陆页面
    否则就进入此页面
    奇怪的是无论条件是true or false 永远进入的都是true 的页面
      

  10.   

    Web.config文件里面是不是把错误指向到errow.aspx?
    调试一下!
      

  11.   

    断点调试一下,单看这里看不出什么问题..另外你在别的页面是怎么用的呢?你把其中一个页面的page_load事件下的代码贴出来看下..
      

  12.   

    protected void Page_Load(object sender, EventArgs e)
        { 
           
            if (!IsPostBack)
            {
                //Server.Execute("check.aspx");
                this.palalter.Visible = true;
                this.palinsert.Visible = false;
                init();
            }
    }
    public void init()
        {
            SqlConnection mycon = DB.myconnection();
            mycon.Open();
            SqlDataAdapter dp = new SqlDataAdapter("select * from cmtion", mycon);
            DataSet ds = new DataSet();
            dp.Fill(ds, "cmtion");
            this.dg.DataSource = ds.Tables["cmtion"].DefaultView;
            this.dg.DataBind();
            mycon.Close();
        }
      

  13.   

    if (Session["flag"] != "true" || Session["type"] != "teacher" || Session["name"] == null|| Session["id"]== null)
    改为:if(!(Session[flag"]==""true" && Session["type"] =="teacher"))
            {
                Response.Redirect("errow.aspx");
            }
    为什么要加入这么多的条件,最好是对不同的类型做出不同的处理。