Session management

J

Justin

Right now, I am managing session state through SQLServer (sessionState
mode="SQLServer").

Any time I am accessing session variable, I know there will be roundtrip
(server hosting the application code to the server hosting the session).

My question is if I am accessing the session variable 5 times in a function,
will this cause 5 roundtrips to the server? (of course you can store session
in a local variable and access that 5 times but I am just curious whether
ASP.NET caches that value). So will the following code cause 5 roundtrips
or 1 roundtrip?

void test()
{
int O = Session["Test"];
int K = Session["Test"];
int L = Session["Test"];
int M = Session["Test"];
int N = Session["Test"];
}

Thanks
 
G

Guest

That' depends on how efficiently you write your code. if you need a Session
value, you only need to get it one time:

int O = Session["Test"];
int K = O;
int L = O;
int M = O;
int N = O;

Hope that helps.
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top