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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:19:51+00:00 2026-06-10T05:19:51+00:00

So, im working in a huge .NET MVC 3 system. As many users could

  • 0

So, im working in a huge .NET MVC 3 system. As many users could be logged in at same time. I was just writting a way of “hey there’s still someone logged with this key” with HttpContext. But, is this the best practice ? is it better to Query DB ?

what i wrote:

     MvcApplication.SessionsLock();

        if (!force && MvcApplication.Sessions.Values.Any(p => p.ID.Equals(acesso.id_usuario.ToString(CultureInfo.InvariantCulture)) && p.Valid))
            throw new BusinessException("There's another user logged with this key. Continue ?");

     MvcApplication.SessionsUnlock();

our I can query my DB.. maybe cookies ? any ideas would be appreciated

  • 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-10T05:19:53+00:00Added an answer on June 10, 2026 at 5:19 am

    Storage

    The database provides a central, durable location for this information. You might use a custom data structure, or ASP.Net SQL session might meet your requirements (more below on this).

    There is not a deterministic way of always knowing exactly when a user’s session ended. For example, you can listen to the Session End event, but it will only fire for in-process sessions and is not guaranteed to fire at all (e.g. the OS could crash).

    Regardless, if you are building a “huge system” as you state, you shouldn’t design against using in-proc session as it won’t scale upwards. Start thinking about SQL-based session state which is more scalable (and may give you enough information to determine roughly how many users are active).

    Session Pro/Con

    I want to know if session is a good practice. That piece of code
    works. But i have been reading a lot of articles deprecating usage of
    sessions on ASP.NET MVC Application.

    As far as Session being a good or bad thing–as always–it depends on how it is used. Properly designed MVC apps can present fairly complex views without needing to preserve state. Part of this is due to strong support for AJAX (no need to reload the page) and elegant model binding (which can take a complex Request.Form and turn it into a complete model).

    Conversely, there is nothing inherently wrong with putting small snippets of repeatedly-used information into session state, using it to avoid sending sensitive data to the client, using it to make a smoother user flow, etc.

    Do beware of session fixation attacks in high-security scenarios. Session may not be appropriate and/or may need to be manually secured further.

    One thing to be aware of is that ASP.Net places a lock on session. This can lead to very real performance issues when multiple requests are made at once. Normally, this isn’t an issue, but consider a page with a dozen AJAX widgets which all requested data from a controller or endpoint that used session. These will contend with each other (firsthand experience).

    • A non-locking in-process ASP.NET session state store

    • https://stackoverflow.com/a/2327051/453277

    MVC provides an easy way to mark a controller as needing only readonly access to Session, which eliminates the issue. However, any read/write activity to Session will still be serialized, so plan accordingly.

    Business Considerations

    From a business perspective it’s not always important to know that the session has expired so much as work has ceased (do you care that they stopped using the site, or that their session timed out?) This can be reliably addressed by checking last modified timestamps on entities and warning the users. Warn, don’t lock. In my opinion, you shouldn rarely/never lock records based on login/logout in a web application (too easy to get stuck in a locked status).

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

Sidebar

Related Questions

I'm working on a huge system based on Asp.net MVC 3.0 and working on
First some background, I am currently working on a relatively large Asp.Net MVC application
I'm working on a RIA system which has a huge number of static resources.
I am trying to learn ASP.NET MVC. After reading through many articles on the
I am currently working on a data management system that needs to calculate huge
I've been working on my first major ASP.NET MVC application (plus lots of jQuery)
I have some terribly written ASP.NET code that is just not working right (go
I am working on an asp.net MVC 3 web application, i have the following
I am working on a few asp.net pages that reside is a huge intranet
I am working with a huge list of URL's. Just a quick question I

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.