Difference between Application variable and Session variable

Application variable

  • Application variables are the variables which remain common for the whole application. Their value can be used across the whole application. 
  • Application variable will be initialized first when your application start.
  • The scope of application variable is across the session and once the variable is set, it can be accessed by any of the user logged into the application.
  • Application variables are application related used by all the user (multiple users). The state maintained in the application variables are shared by all the users. 
  • For example, if you want to count how many users visited your site use application variable.

Session variable

  • 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. The scope of the session variable is just with the session and not accessible across the session.
  • Session variables are browser related used to maintain state for that particular user (single user).
  • Session variable will be reinitialize every time when user make login like
  • For example, if you want to count the current user visiting number then use session variable.

Note:

  • Application variable and session variable both are declared in Global.asax file.
  • 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.

3 comments :

Related Posts with Thumbnails
 

Copyright © 2012. GS dot net - All Rights Reserved - Design by BTDesigner - Proudly powered by Blogger