Thursday, May 27, 2004

Difference between Application Variables and Session Variables

-----Original Message-----
From: Vishal Joshi
Sent: Thursday, May 27, 2004 1:54 PM
To: Rakesh Ambudkar
Subject: RE: What does this mean

I presume that there are 2 types of variables in the discussion below:
Session
Application

Application variables are the variables which remain common for the whole application… Their value can be used across the whole application… And they die only when the application stops or probably when they are killed forcibily… The ideal example for these kindof variables are site counter… We can find out how many people accessed a particular site since the time it went live via application variables and incrementing the same on ever session start..
Session variables are variables which remain common for the whole application but for one particular user. They also can be used across the whole application… But they die when a particular user session ends or probably when they are killed forcibily… The ideal example for this kindof variable are user id… You might want to show "Welcome Vishal" on every page of your site till vishal logs off… So in session start you set a variable to "Welcome Vishal" and kill it on session end…
All these methods like session start, session end, application start, application end are found in global.asax and that’s the reason global.asax is one for the whole ASP.Net application…
I hope this provides you with the info that you needed…
Warm regards,
Vishal Joshi
Ph#: +1-309-763-2242.
If You Think YOU CAN.. You Can...

-----Original Message-----
From: Rakesh Ambudkar
Sent: Thursday, May 27, 2004 12:57 PM
To: Vishal Joshi
Subject: What does this mean


If you use objects with Application scope ,you should be aware that ASP.NET process request concurrently and the applicationobject can be accessed by multiple threads. Therefore following is dagerous and may not produce the desired result ,if the page is repeatedly requested by different clients at the same time.

Thanks
____________________________
Rakesh Ambudkar