Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-03-03
2
Medium Priority
?
415 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 900 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 Ageil
Sammy Ageil earned 600 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

715 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