我用户名,密码验证的时候加了SESSION判断。但始终进不到目标页面。代码如下:
//独立的判断ASPX.    
protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["flag"] == null)
        {
            Response.Redirect("Login.aspx");
        }    }
//目标页面.输入用户名,密码正确,不能输出Hello...。而且又回到Login.aspx.
    protected void Page_Load(object sender, EventArgs e)
    {
            Server.Execute("judge.aspx"); //需要通过Session来判断。
            string UserID = Request.QueryString["UserID"].ToString();
            //Request.QueryString接收
            Response.Write("Hello " + UserID + "");
    }
始终不知道问题在哪里?

解决方案 »

  1.   

    没看出来你哪里写入session了
      

  2.   

    你给session赋值的代码呢?你先不写  Server.Execute("xxxx");
    你直接在你的页面里面用session 判断呢?
    看session是否有值
      

  3.   

    session赋值了没有
      

  4.   

        这样改了,还是不行。直接转到Login.aspx。估计是SESSION没值。
    我怎么检查SESSION的值呢?
    protected void Page_Load(object sender, EventArgs e)
        {
               /* Server.Execute("judge.aspx");*/ //需要通过Session来判断。
            if (Session["flag"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            string UserID = Request.QueryString["UserID"].ToString();
                //Request.QueryString接收
                Response.Write("Hello " + UserID + "");
        }
      

  5.   

     if (!Page.IsPostBack)
    {
     if (Session["flag"] == null)
            {
                Response.Redirect("Login.aspx");
            }
    }
      

  6.   

    楼主看来不懂页面的运作方式,在 Load 事件中写代码一般都要用到 IsPostBack