Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3694818
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:32:32+00:00 2026-05-19T04:32:32+00:00

I need to create a singleton that would hold lots of data for a

  • 0

I need to create a singleton that would hold lots of data for a specific user. However, I am not unclear as to what the behavior of that singleton is in regard to multi-user app requests.

Here is the scenario:

On AppStart event I want to load common data for all users (from SQL) and store it as a collection somewhere within the ASP.NET storage mechanisms. (Any pointers as to where it should go would be greatly appreciated! I am thinking the cache.)

If I store that data in the cache, I would also have to create a static property in the Global.asax that would provide access to that the data from the cache.

This is not ideal because whenever an instance of any particular page, or generic handler, or what have you tries to query this data using Linq the property has to load the data from the cache… introducing latency. I need this data to be immediately available. (think of it as about 5K rows of data stored in collection of objects…)

I was thinking to use a singleton to get that data, and store it but I don’t know how it would behave between requests (and postbacks), as well as application instances, in terms of its persistence.

On PostAuthenticate event I want to get user specific data from SQL in the form of a collection. If i store it as a singleton (in a similar manner as the common data) i am not clear as to:

  1. How is the data persisted?
  2. What is the scope of that singleton (it should be for the duration of the user session).
  3. How can I ensure that the data is immediately available to whatever needs to consume it?
  4. What happens between post-backs to that singleton?
  5. If another user logs in would another instance of that singleton be created for that specific application instance?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:32:33+00:00Added an answer on May 19, 2026 at 4:32 am

    The HttpRuntime cache is a valid place to store your globally shared information. You just have to be aware that it can get purged at any time depending on the cache item settings and available memory. The property you use to access it needs to be able to re-load the data if it’s not found in the cache.

    The runtime cache is an in-process memory store so the overhead for accessing objects is low.

    Alternatively, you can store the data in a shared static property (“singleton”) and it will be available to all users (within a worker-process.)

    You don’t want to store your user/session specific data as a singleton since static instances are shared across all requests. One option is to use Session state to store your user specific data. By default, Session state is also in-process…

    One issue with Session state however is that, unlike the runtime cache, objects aren’t purged in response to memory pressure and will remain in memory until the session expires. This could be a scalability issue if you have lots of concurrent sessions and you are storing large amounts of data in Session state.

    Another option is to use the runtime cache again, but use a composite key such as “UserData|” + UserId to store and retrieve data for each user. This allows you to set time limits on the cached item and the cache will purge old/low priority items if memory gets too low.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create an XML schema that looks something like this: <xs:element name=wrapperElement>
I need to create an ASP page (classic, not ASP.NET) which runs remote shell
I need to create a backup of a SQL Server 2005 Database that's only
I need to create a button that has the same style as ButtonSpec with
I have a method in a singleton class that need to use the .NET
I've next problem: I need create unique user key based on user's information what
I need to create a custom Contains LINQ expression that derives from System.Linq.Expressions.Expression that
I need to create a historical timeline starting from 1600's to the present day.
I need to create a linked server to a DB2 database on a mainframe.
I need to create a 2D int array of size 800x800. But doing so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.