代码如下:
A页面
        tbl_UserBLL userBLL = new tbl_UserBLL();
        string sUserID = this.txt_UserName.Text.Trim();
        string sUserPwd = this.txt_Pwd.Text.Trim();
        string sJs = "";
        tbl_UserInfo user = userBLL.GetUserByAccount(sUserID, sUserPwd);
        if (user != null)
        {            Session["RUNBOW.USER"] = user;
            Response.Redirect("default.aspx");
        }
        else
        {
            sJs = "alert('" + Resources.lang.Login_ErrorInfor + "');";
        }B页面
        try
        {
            tbl_UserInfo tb = (tbl_UserInfo)Session["RUNBOW.USER"];
            string id = tb.ID.ToString();
            if (tb != null)
            {
                if (id == null)
                {
                    Response.Redirect("SysLogin.aspx");
                }
            }
            else
            {
                Response.Redirect("SysLogin.aspx");
            }
        }
        catch
        {
            Response.Redirect("SysLogin.aspx");
        }
-----------------------------------------------------------------------------
我在本地调试和发布B页面都能取到Session。
但是我把代码发布到公司服务器上B就取不到Session值了。
这是为什么啊?是不是哪里写的不对?请高人指教啊。

解决方案 »

  1.   

    try
    IIS里设置Session方法为:
    在IIS里面右键点击默认网站->主目录->应用程序设置里点配置->选项->启用会话状态->会话超时那里设置时间 
      

  2.   

    那个会话状态是启动的,默认的20分钟,但是我这个是登入页面,打开登入之后直接就取不到Session
      

  3.   

    哎,结果自己的还是取不到Session,但是别人用其他电脑访问同一个地址就可以取,郁闷
      

  4.   

    session是服务器对象,应该不是你电脑的问题吧?这个有点费解,从来没遇到过楼主这样的问题,膜拜
      

  5.   

    你本地是不是 禁用了cookie了
      

  6.   

    用Session的话一般都需要Cookie的支持