Solved

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

Posted on 2014-03-03
2
407 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 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
c#, datatable, aspx 4 47
asp.net repeater server posting 5 35
C#:  Need to switch between timer loop and token driven loop 2 28
Adding Rows to Grid 4 28
Running classic asp applications under Windows Server 2008 R2 (x64) and IIS 7 is not as easy as one may think. It took me a while to figure it out while getting error 8002801d a few times. After you install the OS you will need to install the fol…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
Suggested Courses

738 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