Solved

ASP.NET stores data on some static instances - do not persistence

Posted on 2014-03-03
2
393 Views
Last Modified: 2014-03-18
In asp.net I store data on static list so web users can access quickly without having to queries on sql.

From time to time the static list just disappear, when that happen asp.net with queries from sql again.

I which to know what cause the static object to disappear? is it because application pool recycling?

Thx,
0
Comment
Question by:JSW21
2 Comments
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 300 total points
ID: 39902714
Yes, your static object exist as long as IIS process that is servicing your web requests is available.
You are better off using Cache in your page, for example:
http://asp.net-tutorials.com/caching/object-caching/
http://msdn.microsoft.com/en-us/library/aa478965.aspx
http://www.dotnetperls.com/cache
0
 
LVL 27

Assisted Solution

by:Sammy
Sammy earned 200 total points
ID: 39905271
Caching will NOT solve this problem. When the application pool recycles all APP Domain data gets wiped out, this includes, sessions, static objects and cache.
What you need to do is build your list in the Application_Start event. This is the only way to have the list recreated after the application pool recycle.

You can find it or create it in the event in your application's global.asxc.cs
 protected void Application_Start(object sender, EventArgs e)
{
//create your list here
}
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now