Session的定义与使用

以前用Session的时候,总是拿来就用,也没想过先定义再使用,今天就换一种方式。

private void Button1_Click(object sender, System.EventArgs e)
{
System.Web.SessionState.HttpSessionState session = System.Web.HttpContext.Current.Session;//
创建Session
session.Add("test","Test Session");//Session赋值
session.Timeout = 10;//设置会话超时期限,单位为分钟
this.TextBox1.Text = System.Web.HttpContext.Current.Session["test"].ToString();
}

posted @ 2007-10-07 17:23  yellowwood  阅读(894)  评论(0编辑  收藏  举报
Never Give UP