歇台子到兰花小区:asp.net(c#)大家帮我看看,这儿写的session在其它页面读不出来呀,为什么啊?

来源:百度文库 编辑:高校问答 时间:2024/05/03 10:06:46
private void Page_Load(object sender, System.EventArgs e)
{
string vc = RndNum(6);
Session["vvc"]=vc;
SqlConnection conn;
conn= new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["constr"]);
string updateStr = "update sjtp set sjtp = '"+ vc +"' ";
conn.Open();
SqlCommand comm = new SqlCommand(updateStr,conn);
comm.ExecuteNonQuery();
conn.Close();
this.ValidateCode(vc);
}

你在其他页面读Session的时候应该写成:
string 变量名=(string)Session["wc"];
这样就可以了!

在另一个页面你是怎么怎么取的呢?代码贴出来看一下

其他页面是否是同一个Application?