如何获取asp.net会话对象的数据

时间:2015-05-21 09:36:18

标签: asp.net

我正在使用asp.net C#; 我创建了一个这种类型的会话。

如何从此会话中获取数据?

 using (envanterEntities envanter = new envanterEntities())
        {

            kullanicilar kull = new kullanicilar();
            if (envanter.kullanicilar.Any(n => n.kullaniciAdi == txtUser.Text && n.parola == txtPass.Text))
            {
                Session["parola"] = envanter.kullanicilar.First(n=>n.kullaniciAdi==txtUser.Text && n.parola==txtPass.Text);// my session
                Response.Redirect("MainPage.aspx?userName=" + txtUser.Text);
                HttpCookie cookie1 = new HttpCookie("bilgi");
                cookie1.Name = "bilgi";
                cookie1.Expires = DateTime.Now.AddDays(30);
                cookie1.Value = DateTime.Now.ToString();
            }

2 个答案:

答案 0 :(得分:2)

var yoursession=(TheTypeThatFirstReturns)Session["parola"];

答案 1 :(得分:0)

kullanicilar kull1 = (kullanicilar)Session["parola"];