Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 420
  • Last Modified:

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

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
JSW21
Asked:
JSW21
2 Solutions
 
Miguel OzSoftware EngineerCommented:
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
 
Sammy AgeilCommented:
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now