由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
DotNet版 - A Question about Session State in ASP.NET
相关主题
c# 内存管理的一个小问题[转载] 最近要用VC#.net编成,请教一下
CrystalReport 问题请推荐asp.net的书!
请问, ASP.NET 中, 2 个web form之间如何传参数?MSDN 上的相关新闻组
觉得C#的valuetype和boxing真的是没有必要How to write Virtual Channel Application
I need build a bulletin board on .NET, suggestions. Help.谁有PDC WHIDBEY DOWNLOAD?
Question about Explicit interface members in c#怎么publish ASP.NET web
Ndoc - .Net's javadocWhidbey
MSDN 上的PATTERN 资源请各位老大分享一下exception的使用经验吧。
相关话题的讨论汇总
话题: session话题: object话题: question话题: state话题: what
进入DotNet版参与讨论
1 (共1页)
d*****t
发帖数: 17
1
Hi, All,
I have been confused by a seemingly simple question for a few days. Hope
anyone could give me some suggestion.
What bothers me is that ASP.NET seems to be able to remember the state of an
object after I put that object into the Session property. As you can find
in my code, I didn't explicitly save the object back to the Session property
after I changed it. But the state of the object seems to be updated in
following requests. Did I miss anything here? Thanks in advance.
Below is my code
l*s
发帖数: 783
2
This is how it suppose to work.
You are storing the arraylist object in the session and it's going to be the
'same' object whenever you retrieve it afterwards. And this arraylist
object has the references to the string items.

an
property

【在 d*****t 的大作中提到】
: Hi, All,
: I have been confused by a seemingly simple question for a few days. Hope
: anyone could give me some suggestion.
: What bothers me is that ASP.NET seems to be able to remember the state of an
: object after I put that object into the Session property. As you can find
: in my code, I didn't explicitly save the object back to the Session property
: after I changed it. But the state of the object seems to be updated in
: following requests. Did I miss anything here? Thanks in advance.
: Below is my code

d*****t
发帖数: 17
3
Thanks for your answer. So it seems that what Session has is a reference to
the original object (not a clone of the object), which explains why no
explicit saving back of the object is necessary. I did try to manipulate
variables of primitive data types (such as int) in Session in the same way
but I had to save the variable back to Session every time after I changed it
. It is strange that none of the books I went through mentioned this matter,
neither does MSDN (or maybe I just didn't find it).

【在 l*s 的大作中提到】
: This is how it suppose to work.
: You are storing the arraylist object in the session and it's going to be the
: 'same' object whenever you retrieve it afterwards. And this arraylist
: object has the references to the string items.
:
: an
: property

l*s
发帖数: 783
4
This is not specific to session object. You need to read about value type/
reference type;boxing/unboxing;pass by value/pass by reference

to
it
matter,

【在 d*****t 的大作中提到】
: Thanks for your answer. So it seems that what Session has is a reference to
: the original object (not a clone of the object), which explains why no
: explicit saving back of the object is necessary. I did try to manipulate
: variables of primitive data types (such as int) in Session in the same way
: but I had to save the variable back to Session every time after I changed it
: . It is strange that none of the books I went through mentioned this matter,
: neither does MSDN (or maybe I just didn't find it).

d*****t
发帖数: 17
5
My initial impression was that when objects were stored in a Session, their
clones were placed in a domain (such as SQL Server) separate from the
application domain. This is why I posted my original question. But now it
seems that only references are saved in session, even if an out-of-process
mode is used in Session. A

【在 l*s 的大作中提到】
: This is not specific to session object. You need to read about value type/
: reference type;boxing/unboxing;pass by value/pass by reference
:
: to
: it
: matter,

s******g
发帖数: 120
6
Not sure what your question is. Do you want to share what your expected page
result is?
To me, your code is clear as: session stores an array of string values. as
long as it is postback, the session value won't be cleaned up. So if you
enter ABC, click button and then enter DEF, click button, it will show:
ABC
DEF
what was the result you were expecting from your original impression?
1 (共1页)
进入DotNet版参与讨论
相关主题
请各位老大分享一下exception的使用经验吧。I need build a bulletin board on .NET, suggestions. Help.
在C#里面怎么创建SDI,MDI之类得程序?Question about Explicit interface members in c#
问个c# treeview的问题Ndoc - .Net's javadoc
你们如何test asp.net page?MSDN 上的PATTERN 资源
c# 内存管理的一个小问题[转载] 最近要用VC#.net编成,请教一下
CrystalReport 问题请推荐asp.net的书!
请问, ASP.NET 中, 2 个web form之间如何传参数?MSDN 上的相关新闻组
觉得C#的valuetype和boxing真的是没有必要How to write Virtual Channel Application
相关话题的讨论汇总
话题: session话题: object话题: question话题: state话题: what