使用Session对象 [英] Using the Session object

查看:55
本文介绍了使用Session对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简单的问题,我认为...


我在Session对象中存储一个对象。


代码后面我读了那个对象:trx = CType(Session(" Transaction"),BOCSTransaction)


如果我更改了任何属性,我必须将它存回到会话对象中去;更新"对的?或者我的对象的更改会自动保存回会话对象吗?


谢谢,

Jerry

Simple question, I think...

I''m storing an object in the Session object.

In the code behind I read that object: trx = CType(Session("Transaction"), BOCSTransaction)

If I change any properties, I have to store it back into the session object to "update" it, right? Or will the changes to my object automatically be saved back into the session object?

Thanks,
Jerry

推荐答案

Jerry,


你是对的,你必须更新会话变量,没有自动链接。


Eliyahu


< rl ***** @ newsgroups.nospam>在留言新闻中写道:em ************* @ TK2MSFTNGP09.phx.gbl ...

简单的问题,我想......


我在Session对象中存储一个对象。


在后面的代码中我读了那个对象:trx = CType(Session(" Transaction")) ,BOCSTransaction)


如果我更改了任何属性,我必须将其存储回会话对象中以更新。对的?或者我对象的更改会自动保存回会话对象吗?


谢谢,

Jerry
Jerry,

You are right, you have to update session variables, there is no automatic link.

Eliyahu

<rl*****@newsgroups.nospam> wrote in message news:em*************@TK2MSFTNGP09.phx.gbl...
Simple question, I think...

I''m storing an object in the Session object.

In the code behind I read that object: trx = CType(Session("Transaction"), BOCSTransaction)

If I change any properties, I have to store it back into the session object to "update" it, right? Or will the changes to my object automatically be saved back into the session object?

Thanks,
Jerry

它们都是对堆(内存)中相同空间的引用。当你将它分配给一个新变量时,你只能在内存中获得该空间的句柄。


所以你的猜测都是错误的。您不必将其存储在会话中,但这并不是因为它会自动保存回会话对象。


相反,您不必将其保存回会话的原因是因为此对象只有1个实例(除非您克隆它),因此任何指向该位置的变量所做的更新都将反映在所有其他变量也指向那里。


Karl


-

我的ASP.Net教程
http://www.openmymind.net/

< rl ***** @newsgroups.nospam>在留言新闻中写道:em ************* @ TK2MSFTNGP09.phx.gbl ...

简单的问题,我想......


我在Session对象中存储一个对象。


在后面的代码中我读了那个对象:trx = CType(Session(" Transaction")) ,BOCSTransaction)


如果我更改了任何属性,我必须将其存储回会话对象中以更新。对的?或者我对象的更改会自动保存回会话对象吗?


谢谢,

Jerry
They are all references to the same space in the heap (memory). When you assign it to a new variable, you are only getting a handle on that space in memory.

So both your guesses are wrong. You don''t have to store it back in the session, but that isn''t because it''s automatically "saved back into the session object".

Rather, the reason you don''t have to save it back into the session is because there''s ever only 1 instance of this object (unless you clone it) and thus updates made by any variable that point to that location will be reflected in all other variables that point there also.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
<rl*****@newsgroups.nospam> wrote in message news:em*************@TK2MSFTNGP09.phx.gbl...
Simple question, I think...

I''m storing an object in the Session object.

In the code behind I read that object: trx = CType(Session("Transaction"), BOCSTransaction)

If I change any properties, I have to store it back into the session object to "update" it, right? Or will the changes to my object automatically be saved back into the session object?

Thanks,
Jerry

我们中的一个人根本就错了......


加载测试..


Eliyahu Goldin <再************* @ monarchmed.com>在留言新闻中写道:u9 ************** @ tk2msftngp13.phx.gbl ...

Jerry,


你是对的,你必须更新会话变量,没有自动链接。


Eliyahu


< rl **** *@newsgroups.nospam>在留言新闻中写道:em ************* @ TK2MSFTNGP09.phx.gbl ...

简单的问题,我想......


我在Session对象中存储一个对象。


在后面的代码中我读了那个对象:trx = CType(Session(" Transaction")) ,BOCSTransaction)


如果我更改了任何属性,我必须将其存储回会话对象中以更新。对的?或者我对象的更改会自动保存回会话对象吗?


谢谢,

Jerry
one of us is fundamentally wrong...

loading up a test..

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message news:u9**************@tk2msftngp13.phx.gbl...
Jerry,

You are right, you have to update session variables, there is no automatic link.

Eliyahu

<rl*****@newsgroups.nospam> wrote in message news:em*************@TK2MSFTNGP09.phx.gbl...
Simple question, I think...

I''m storing an object in the Session object.

In the code behind I read that object: trx = CType(Session("Transaction"), BOCSTransaction)

If I change any properties, I have to store it back into the session object to "update" it, right? Or will the changes to my object automatically be saved back into the session object?

Thanks,
Jerry

这篇关于使用Session对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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