日期:2014-05-17  浏览次数:20984 次

session取不到值
代码如下,第一页保存了一个Session["yonghuming"],第二页 yhm = Session["yonghuming"].ToString();却没有获得原Session的值。请高手赐教!
注:把第二页的 yhm = Session["yonghuming"].ToString();换成yhm = "aaa"; 时会有反应,说明已经进行到这一步了,只是取不到原Session的值。


第一页:

public partial class web_login : System.Web.UI.Page
{
    ......
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            
        }
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        if (this.txtCode.Text.ToString() == Request.Cookies["CheckCode"].Value.ToString())
        {
            if (bll.CheckLogin(Number, password))
            {
                if (bc.userLimit(Number))
                {
                    //将用户名保存到session
                   Session["yonghuming"] = this.txtNumber.ToString();
                   Session.Timeout = 600;

                   }
              }
          }
    }
}


第二页:

public partial class web_option : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
           .....
        }
    }
    protected void Repeater3_ItemDataBound(object sender, RepeaterItemEventArgs e)