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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:15:29+00:00 2026-05-13T18:15:29+00:00

I have a custom ASP.NET session manager class as follows: public sealed class SessionManager

  • 0

I have a custom ASP.NET session manager class as follows:

public sealed class SessionManager : Page
    {
        private const string USER = "User";

        private static readonly SessionManager _instance = new SessionManager();

        private SessionManager()
        {
        }


        public static SessionManager Instance
        {
            get { return _instance; }
        }


        public User User
        {
            get { return Session[USER] as User; }
            set { Session[USER] = value; }
        }

    }

After a user successfully logs into the system his full name is displayed on the Home page. Below is the problem I am facing:

1) I first log into the system as John and John’s full name is displayed on the homepage and the corresponding user object is kept in session.

2) Now from a different PC I login to the system as Mark. Now Mark’s full name is displayed on the homepage and the corresponding user object is kept in session.

3) Now when I go to the PC from which John has logged in and refresh the homepage I see Marks name instead of Johns name.

What could be the reason for this strange behavior?

  • 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-13T18:15:29+00:00Added an answer on May 13, 2026 at 6:15 pm

    Your class inherits from System.Web.UI.Page, which sets its Session member to HttpContext.Current.Session on first access. Since you have a singleton, it will always refer to the first session in which the User property was accessed.

    You probably should do something like this:

    public sealed class SessionManager
    {
        private const string USER = "User";
    
        private static readonly SessionManager _instance = new SessionManager();
    
        private SessionManager()
        {
        }
    
        public static SessionManager Instance
        {
            get { return _instance; }
        }
    
        public User User
        {
            get { return HttpContext.Current.Session[USER] as User; }
            set { HttpContext.Current.Session[USER] = value; }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom Asp.net control as public class ImageControl : Panel { private
I have made a custom error page for my ASP.NET 4 application. I put
I have a custom asp.net server control to display images.What I need now is
I'm writing a custom ASP.NET webcontrol and would like it to have a collection
In my asp.net mvc3 application, I have a custom Authorization Attribute as seen below.
I have a custom memebership provider that has served us well for asp.net web
I have a asp.net webpage that contain a custom login control like this: <div
I have an ASP.NET application that uses a custom .NET library (a .DLL file).
i have an ASP.NET web service that returning a custom entity object (Staff): [WebMethod]
I have an ASP.NET project which has already some custom fields in it's web.config

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.