473,545 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using the Session object

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
Jan 23 '06 #1
13 1737
Jerry,

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

Eliyahu

<rl*****@newsgr oups.nospam> wrote in message news:em******** *****@TK2MSFTNG P09.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
Jan 23 '06 #2
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*****@newsgr oups.nospam> wrote in message news:em******** *****@TK2MSFTNG P09.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
Jan 23 '06 #3
one of us is fundamentally wrong...

loading up a test..

"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message news:u9******** ******@tk2msftn gp13.phx.gbl...
Jerry,

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

Eliyahu

<rl*****@newsgr oups.nospam> wrote in message news:em******** *****@TK2MSFTNG P09.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
Jan 23 '06 #4
Doesn't the concept of "references " form an automatic link. If he modifies the variable "trx", then that would also be reflected back in the session version, right? Unless the value stored in the session is a value type.

"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message news:u9******** ******@tk2msftn gp13.phx.gbl...
Jerry,

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

Eliyahu

<rl*****@newsgr oups.nospam> wrote in message news:em******** *****@TK2MSFTNG P09.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
Jan 23 '06 #5
That's what I said, and I just tried it out to make sure I wasn't bonkers.

I'm not familiar with BOCSTransaction so anything's possible, but I think Peter and I are right on this one.

Karl

"Peter Rilling" <pe***@nospam.r illing.net> wrote in message news:uL******** *****@TK2MSFTNG P15.phx.gbl...
Doesn't the concept of "references " form an automatic link. If he modifies the variable "trx", then that would also be reflected back in the session version, right? Unless the value stored in the session is a value type.

"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message news:u9******** ******@tk2msftn gp13.phx.gbl...
Jerry,

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

Eliyahu

<rl*****@newsgr oups.nospam> wrote in message news:em******** *****@TK2MSFTNG P09.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
Jan 23 '06 #6
> That's what I said, and I just tried it out to make sure I wasn't bonkers.

I'm not familiar with BOCSTransaction so anything's possible, but I think
Peter and I are right on this one.

Karl
If "BOCSTransactio n" is an object, then this is true (just the
reference is stored in Session, so you are updating the "real" object).
However (just to be complete), if "BOCSTransactio n" is a struct
(ValueType, sorry, don't know the VB name) then you will get a *copy*
of the stored struct. So then you *will* have to "store back" the
changed struct.

Hans Kesting


"Peter Rilling" <pe***@nospam.r illing.net> wrote in message
news:uL******** *****@TK2MSFTNG P15.phx.gbl... Doesn't the concept of
"references " form an automatic link. If he modifies the variable "trx", then
that would also be reflected back in the session version, right? Unless the
value stored in the session is a value type.

"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:u9******** ******@tk2msftn gp13.phx.gbl... Jerry,

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

Eliyahu

<rl*****@newsgr oups.nospam> wrote in message
news:em******** *****@TK2MSFTNG P09.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

Jan 23 '06 #7
this is only true if the whats stored is session is an object. if its a value type (int, structure, etc), then you need to replace the session object.

also there are differences depending on the session manager. a inproc session manager hold a reference to the object until replaced or the session expires. an out-proc session manager (state, sqlserver), only references the object during the request, at request end, its serialized out. this means you can reference a session variable between requests (say a background thread) with a inproc session handler but not in out of proc hander. \

aslso if you store the same object twice in the session, if in proc they are the same object and stay the same, but in an out of proc session, they become seperate object on the next request.

-- bruce (sqlwork.com)

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:Ox******** ******@TK2MSFTN GP11.phx.gbl...
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*****@newsgr oups.nospam> wrote in message news:em******** *****@TK2MSFTNG P09.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
Jan 23 '06 #8
Okay... Thanks everyone for their input.

This is my understanding.. .

BOCSTransaction is my own class, so it's an object stored, apparetly, by reference in the Session and I don't need to update the Session every time I change a property of it.

I'm still kinda new to the web architecture. I just wasn't sure if objects were serialized into some common space when you stored them in the Session. If it is truly just a heap pointer, then it's easy. Thanks.

Jerry

<rl*****@newsgr oups.nospam> wrote in message news:em******** *****@TK2MSFTNG P09.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
Jan 23 '06 #9
Assume that we're using Inproc session, then all the variables held in
session state are in-memory objects. So whether we can directly modify the
object without reassign it back to the sessionstate entry depend on its
class type. If it's of reference type, the session state entry just hold
the reference to that object, so we can certainly just update it without
explicitly reassign. If a value type, reassign is necessary....

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Subject: Re: =?UTF-8?B?VXNpbmcgdGh lIFNlc3Npb24gb2 JqZWN0?=
| From: "Hans Kesting" <ne***********@ spamgourmet.com >
| References: <em************ *@TK2MSFTNGP09. phx.gbl>
<u9************ **@tk2msftngp13 .phx.gbl>
<uL************ *@TK2MSFTNGP15. phx.gbl>
<uH************ **@TK2MSFTNGP14 .phx.gbl>
| Message-ID: <mn************ ***********@spa mgourmet.com>
| X-Newsreader: MesNews/1.04.01.00-gb
| Date: Mon, 23 Jan 2006 18:03:03 +0100
| MIME-Version: 1.0
| Content-Type: text/plain; charset="utf-8"; format=flowed
| Content-Transfer-Encoding: 8bit
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: 127-24.bbned.dsl.in ternl.net 82.215.24.127
| Lines: 1
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP15.phx. gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3729 24
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| > That's what I said, and I just tried it out to make sure I wasn't
bonkers.
| >
| > I'm not familiar with BOCSTransaction so anything's possible, but I
think
| > Peter and I are right on this one.
| >
| > Karl
|
| If "BOCSTransactio n" is an object, then this is true (just the
| reference is stored in Session, so you are updating the "real" object).
| However (just to be complete), if "BOCSTransactio n" is a struct
| (ValueType, sorry, don't know the VB name) then you will get a *copy*
| of the stored struct. So then you *will* have to "store back" the
| changed struct.
|
| Hans Kesting
|
|
| >
| > "Peter Rilling" <pe***@nospam.r illing.net> wrote in message
| > news:uL******** *****@TK2MSFTNG P15.phx.gbl... Doesn't the concept of
| > "references " form an automatic link. If he modifies the variable
"trx", then
| > that would also be reflected back in the session version, right?
Unless the
| > value stored in the session is a value type.
| >
| > "Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
| > news:u9******** ******@tk2msftn gp13.phx.gbl... Jerry,
| >
| > You are right, you have to update session variables, there is no
| > automatic link.
| >
| > Eliyahu
| >
| > <rl*****@newsgr oups.nospam> wrote in message
| > news:em******** *****@TK2MSFTNG P09.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
|
|
|

Jan 24 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2439
by: Abhilash.k.m | last post by:
This is regarding the session management using Out of proc session management(SQL SERVER). Among the samples below which one is better to set the session? 1. There are 20 session variables and all of them are being stored into session and accessed from session and individual session object. Example: Session = "XYZ", Session=100,...
9
2368
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first released & it really shouldn't be this hard to use - perhaps I'm just not very smart or perhaps MS is making this too hard for us sql bunnies to understand - I dunno, but I'd really appreciate someone...
4
2793
by: Kevin Phifer | last post by:
Ok, before anyone freaks out, I have a solution I need to create that gathers content from maybe different places. Each one can return a <form> in the html, so its the classic can't have more than one runat=server form on a asp.net page. However, I still want developers to be able to use asp.net controls to create some apps that are created...
1
6397
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and binding it to a repeater control. This repeater control has multiple text boxes and buttons. Can you please tell me how can i do paging in this case ?...
15
2399
by: Joe Fallon | last post by:
I would like to know how you can figure out how much memory a given instance of a class is using. For example, if I load a collection class with 10 items it might use 1KB, and if I load it with 1000 items it might use 100KB. How do I measure the amount of memory used once the class is loaded? Thanks! -- Joe Fallon
9
1525
by: viz | last post by:
hi, i have written a class for session handling, and i want to use it to keep track of the user. After authenticating the user in login page i am storing the session info like uname etc.. in a object of session class. I am creating this object in the login page. Now how can i make this object persist between subsequent page requests. and...
7
7307
by: Rob | last post by:
Hi, I'm getting an error on my login page when using Javascript session object. It works on the development server so I'm wondering if there is a setting in IIS to allow using sessions on the server. When the user clicks on the submit button after entering their username and password, it calls a function (below) and I get an "Object...
0
2541
by: Eugene Anthony | last post by:
The problem with my coding is that despite removing the records stored in the array list, the rptPages repeater control is still visible. The rptPages repeater control displayes the navigation link (1,2,3 so on). The code can be found in SubscriptionCart.aspx.cs. Default.aspx ------------
0
1587
by: srinivas srinivas | last post by:
Hi, I am developing simple peer-peer RTC application for monitoring the SDP packets and i need to set the TLS security for the transport. But iam struggling to achieving this. Iam using IP addresses as SIP URI for communication. I am using IRTCClientProvisioning::GetProfile() IRTCClientProfile::EnablePrsenceEx()...
0
7475
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7921
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5982
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4958
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3465
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
720
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.