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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:49:17+00:00 2026-05-20T07:49:17+00:00

I am creating an ASP.NET application that allows users to edit and insert data

  • 0

I am creating an ASP.NET application that allows users to edit and insert data that is persisted in a SQL Server database. I would like to implement a controller class that handles queries for certain entities, caches results and triggers events when data is inserted or updated. I need one of these controller classes for each entity in my data model. What I’m unsure of is how to create a singleton class of this sort that different user sessions can access.

For example, I have a Employee entity in my data model. I would like to have an EmployeeController class that handles retrieving the employees from the database, sends inserts and updates to the database, keeps a cache of all employees and triggers events when an employee is inserted or updated. Objects in other user sessions could then listen and respond to these events.

So:

  • Am I on the right track?
  • Should I be using the ASP.NET MVC framework to accomplish this?
  • How do I instantiate these controller classes when the first user needs them and have subsequent concurrent users access the same class?

EDIT:

I’ve been researching the idea of a controller class as an anti-pattern since @TomTom’s answer. I’m not convinced one way or the other.

I still need an answer to question #3 above. Let’s just drop the specific idea of a controller class for now. How do I create any class that is:

  1. accessible by multiple user sessions,
  2. allows only one instance,
  3. is deleted if there are no user sessions, and
  4. triggers events that other classes can listen to.
  • 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-20T07:49:18+00:00Added an answer on May 20, 2026 at 7:49 am

    First of all, the term “Controller” is already used in MVC, and is indeed the C in MVC. You don’t want to confuse the two.

    What you are actually describing is more like the Repository pattern, although without the singleton nature. It’s certainly possible, using Inversion of Control and a Dependancy Injection container to make repositories singletons.

    However, the bigger problem you’re going to have is that sessions are imaginary in web applications. They don’t really exist (despite the attempts by frameworks to make you think they do).

    Essentially, a web applicaiton only exists when someone is actively connected to the site, and is posting or getting HTTP data. As soon as the request is done, the app is basically in limbo. After a certain period of inactivity, even the fake session times out and then there is nothing, until the next person connects.

    So, the concept of “cross session” really is meaningless in a web application, because you will never know when someone else is connected or not, whether or not you can actually fire events to other sessions, etc… It will be a huge pain in the ass, error prone at best, and a disaster at worst.

    Your best bet is simply create an “event” table in your database that each session can check everytime they do something. Then you can do whatever you want with those events. Just remember, the web is stateless.

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

Sidebar

Related Questions

I am creating an ASP.NET application that allows the user to add form elements
Working inside the context of an ASP.NET application I am creating a page that
I'm creating an ASP.NET web application to schedule tasks on our server from a
I've got an ASP.NET application that uses the CreateUserWizard to register new users. Part
I am creating a ASP.NET application that is pretty much self contained, it will
How do I go about creating a mock request for my asp.net-mvc application for
I am creating a mobile web application using asp.net. The application must support iPhone,
When I'm creating a user for my web application, an SMTP email (using ASP.NET's
I'm creating an asp.net app with just some lite data access from xml files.
I'm creating a small app in ASP.NET MVC that generates ics (iCal) files based

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.