如何在Session变量中设置Object? [英] How set Object in Session variable?

查看:136
本文介绍了如何在Session变量中设置Object?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Session变量中设置Object?谢谢

解决方案

根据我的想法,你想问一下如何在会话中存储对象...它变得很容易

 Session [YourObjectKey] = object 



并从会话中检索对象就像

 //假设学生是你的班级名字
学生sObj =(学生)课程[YourObjectKey];


会话变量可以存储任何类型的数据,内存最大为2.2GB,具体取决于App_pool的大小



这里你可以保存/分配任何值到会话变量









会话[  SessionVar] = objYourObjectName; 


在会话中分配值的另一种方式

Session.Add(Key,Value);

How set Object in Session variable?Thanks

解决方案

as per my understading u want to ask that how to store object in session... its vary easy like

Session["YourObjectKey"] = object


and retrieve the object from the session is like

//Assume Student is your Class name
Student sObj = (Student)Session["YourObjectKey"];


Session variable can store any type of data in it with memory up to 2.2GB depend on size of your App_pool

here you can save/assign any value into a session variable




Session["SessionVar"] = objYourObjectName;


another way to assign value in the session
Session.Add(Key,Value);


这篇关于如何在Session变量中设置Object?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆