我如何才能将会话称为对象 [英] How can i call a session into a object
本文介绍了我如何才能将会话称为对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个将其存储在session ["asp"]中的对象.当我转到另一个页面时,我想在那里调用相同的对象.我使用了这样的代码
Hi,
I have a object i stored this in a session["asp"]. when i am going to another page i want to call the same object there. i used the code like this
//storing the object in session
Session["asp"] = objSer;
//in another page i am calling the session to store in new object and i have some thing to check there
object objserials =Session["asp"];
我无法获取会话计数,这意味着我有5个值
以及objserials. (什么都没有,一些默认值也来了.)
问候,
s.Basha
i am unable to get the count of the session, means i have 5 values in it
and if objserials. (nothing is comming, some default values are coming.)
Regards,
s.Basha
推荐答案
您必须将其转换为适当的类型.因此,如果objSer
是int
,则必须执行以下操作:
You have to cast it to the appropriate type. So, ifobjSer
was anint
, you''d have to do this:
int value = (int)Session["asp"];
或者,更恰当的是:
or, more appropriately:
int value;
Int32.TryParse(Session["asp"], out value);
这篇关于我如何才能将会话称为对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文