what is the difference between session state and application state?

Posted by Udaysimha under ASP.NET on 1/27/2012 | Points: 10 | Views : 35211 | Status : [Member] | Replies : 9
HI,

please let me know the difference between session state and application state in asp.net
Thanks

uday


Responses

Posted by: SheoNarayan on: 1/27/2012 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Session state

It is specific to user.

eg.
Session["myData"] = "Ram";


Now the value of Session["myData"], ie. Ram will be available only to that user who has saved this data, if other user is saving different value in Session["myData"], that value will be available to that user.

Application state

It is specific to Application that is data saved into Application is same for all user ie. it is global, if different user is changing the value of Application["myData"], it will be changed for all users.
eg.

Application["myData"] = "Something";


Now Application["myData"] value will be available to all users; if another user changes its value, the changed value will be available to all other users.

Hope this clarifies your doubt.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Udaysimha, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 6/12/2012 [Member] Silver | Points: 25

Up
0
Down
A session is usually for a user and only lasts from when they login to when they logout (or get timed out). Application State has a much longer lifetime, is shared between all users, and is only cleared when the process is restarted.
http://stackoverflow.com/questions/5330584/what-is-the-difference-between-application-state-and-application-session

Udaysimha, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 6/23/2012 [Member] Silver | Points: 25

Up
0
Down
Mark as Answer if its helpful to you,that motivates...

Udaysimha, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 6/23/2012 [Member] Silver | Points: 25

Up
0
Down
Mark as Answer if its helpful to you,that motivates...

Udaysimha, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muralidosscm on: 6/25/2012 [Member] Starter | Points: 25

Up
0
Down
Application State : Data stored in the application object can be shared by all the sessions of the application. Application object stores data in the key value pair.

Session State: Session State stores session-specific information and the information is visible within the session only. ASP.NET creates unique sessionId for each session of the application. SessionIDs are maintained either by an HTTP cookie or a modified URL, as set in the applications configuration settings. By default, SessionID values are stored in a cookie.

Regards
Muralidoss M

Udaysimha, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajkatie on: 6/25/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
you can also refer following link
http://venkataspinterview.blogspot.in/2008/07/aspnet-session-state-and-application.html

Rajesh Patel
.Net Trainer(MSCD | MCT | MS)
Brainbench (Asp.Net 4.5 and C# 5.0)

Udaysimha, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mkumar on: 7/16/2013 [Member] Starter | Points: 25

Up
0
Down
Both are state management techniques for web pages.Session is for each user i.e when one user stores some data in session ,session data cab be accessed by only that user .while Application works for all user globally when any user comes to the web page, the same data stored in application is used for all user.
Application is faster than session .

mkumar

Udaysimha, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response