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 8193235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:24:57+00:00 2026-06-07T04:24:57+00:00

So, An object that uses the singleton pattern can only have one instance. How

  • 0

So, An object that uses the singleton pattern can only have one instance. How does this work on websites?

Questions:

  1. Is the singleton object unique to each client/visitor of the website? i.e. Do singleton objects get one instance PER client?
  2. Objects in web applications only last for a few seconds, so if two clients simotaneously access a website both clients would be trying to create a singleton object. Does this mean one would have an exception thrown that visitors will see? I tried googling, but couldn’t find a direct answer. I’m just looking for a little clarification.
  • 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-06-07T04:24:58+00:00Added an answer on June 7, 2026 at 4:24 am

    Steve, I’ll try to answer each of your questions:

    1) For web development it is very common to have objects scoped to the web request (sometimes this is also referred to as “per request context” or “per http context”), but we typically don’t refer to these as singletons for that exact reason. Most IOC containers in fact have a “per web request” scope built into them out of the box as well as a “singleton”.

    2) It is common to sometimes have true singletons for a web application as well (accessed by all requests). As mentioned above this isn’t completely true because it’s going to be scoped to the app pool and will be blown away when/if the app pool is restarted. But this is a singleton for the purposes of the web application. As Jigar mentioned, sometimes “cross-cutting concerns” such as logging etc…are set up this way. These are typically not initialized in each web request but instead in the global.asax or by relying on an IOC container to do this for you. You just have to be sure when performing object creation to use one of the standard locking patterns to prevent two threads/clients/etc… from simultaneously creating the object. Here’s a link from Microsoft but there are other implementations out there as well: http://msdn.microsoft.com/en-us/library/ff650316.aspx If you are using one of the popular IOC containers it will take care of this for you (Structuremap, Windsor, Autofac, Unity, Ninject…and many others).

    You’d need to ask your coworkers which approach they are referring to because both are valid in certain situations and very common.

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

Sidebar

Related Questions

I have a datastore object that uses one of the fields in the class
I have a singleton that uses the static readonly T Instance = new T();
When would the garbage collector erase an instance of an object that uses Singleton
I have a web application that uses the CDO Message object to email reports.
I have a flex 3 app that uses netstream and a video object to
I currently have a Javascript function that uses a string to reference an object
I have created an app in C# .Net 2.0 that uses the AxShockwaveFlash object
I know that Singleton pattern is bad because it uses global state. But in
I have created objects that are interfaces to a web service. One typical object
I've got an object that uses System.Version as a property. I want this object

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.