为什么 获取 session 为 null ?
按钮点击代码protected void Button1_Click(object sender, EventArgs e)
{
......前面省略
string name = this.name.Text.Trim().ToString();
string accountPassword = this.accountPassword.Text.Trim().ToString();
string email = this.email.Text.Trim().ToString();
Session["name"] = name;
Session["accountPassword"] = accountPassword;
Session["email"] = email;
Response.Redirect("registerSuccess.aspx");
}
在另外一个页面( registerSuccess.aspx )获取出错
public partial class registerSuccess : System.Web.UI.Page
{
private DataSet ds = new DataSet();
private SqlDataAdapter dataAdapter = new SqlDataAdapter();
private EcrdCardInfoDAO cardInfoDAO = new EcrdCardInfoDAO();
private EcrdCardDAO cardDAO = new EcrdCardDAO();
protected void Page_Load(object sender, EventArgs e)
{
string email = Session["email"].ToString();//我用了断点,这里显示email为空,为什么?
ds = cardInfoDAO.SelectByEmail_EcrdCardInfo(email);
if (ds == null)
{
dataAdapter.Fill(ds, "t1");
GridView1.DataSource = ds.Tables["t1"];
GridView1.DataBind();
}
else
{
string name = Session["name"].ToString();
ds = cardDAO.SelectByName_EcrdCard(name);
dataAdapter.Fill(ds, "t1");
GridView1.DataSource = ds.Tables["t1"];
GridView1.DataBind();
}
}
}