Support us .Net Basics C# SQL ASP.NET Aarvi MVC Slides C# Programs Subscribe Download

Asp.net Application state - Part 67

Suggested Videos
Part 64 - Inporc asp.net session state mode management
Part 65 - StateServer asp.net session state mode management
Part 66 - SQLServer asp.net session state mode management

1. Application State variables are available across all pages and across all sessions. Application State variables are like multi-user global data.

2. Application State variables are stored on the web server.

3. Application State variables are cleared, only when the process hosting the application is restarted, that is when the application ends. 

4. Application State variables are not shared across a Web Farm or a Web Garden.



5. Application state variables are not thread safe. Lock and Unlock methods of the application class must be used to protect against race conditions, deadlocks, and access violations.
Application.Lock();
Application["GlobalVariable"] = (int)Application["GlobalVariable"] + 1;
Application.UnLock();

Please Note: In this example, we are using application state variables to send data from one web form to another. If the requirement, is just to send data from webform to another, you should consider other alternatives.

6. Use application state variables only, when the variables need to have global access and when you need them for entire time, during the life time of an application. Cache object, can be used, as an alternative, if you need to have global access for a certain duration.



1 comment:

  1. Please share one video on How to use Cache Objects as one alternatives to Application State?

    ReplyDelete

It would be great if you can help share these free resources