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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:11:01+00:00 2026-06-12T12:11:01+00:00

I have a base Controller which all the controllers extend, and at base controller

  • 0

I have a base Controller which all the controllers extend, and at base controller I do some session handling. Such as storing user id etc.

Moreover, I have a User class which has other classes such as :

class User
{
   public int Id {set;get;}
   public virtual Location Location {set;get;}
}

When i populate this from Database (i m using code first EF), obviously Location wont load, Should i store this in the session the way it s?

Main question is I am storing Id in base controller and losing the session everytime i restart the application. why is that happening? i extended session timeout and didnt help.

What are the best practices for session handling? is there a wrapper i can use?

  • 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-12T12:11:02+00:00Added an answer on June 12, 2026 at 12:11 pm

    Re: storing User in session: You can, just make sure you don’t ever access the ‘Location’ property without re-attaching it to a session. If you don’t need the data, an option is to just copy the data you do need into a simpler object that doesn’t have ‘Location’ and store that in your Session.

    Re: losing the session context, that’s because the default is to store session data in memory, which is lost whenever the application restarts. Take a look at using the StateServer mode for session if you want that state to persist across application restarts (though if you want to persist server restarts or work in a multi-server farm, you’ll want to go the SQLServer route).

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

Sidebar

Related Questions

I have created a Base-Controller from which all the controllers inherit. Currently this controller
I have an abstract base Controller class and all action controllers are derived from
I have my own inherited App.Controller from Mvc.Controller which then all of my controllers
All my controllers in my project inherit from a base controller, which has a
I have a base controller which is defined as follows, but the constructor that
I have a controller that all my controllers inherit from and I need to
I have a bunch of Rails 3.1 controllers which all have very similar testing
I have a base controller class that exposes some logging functionality to it's child
I have an ActionFilter that is applied to my base controller which checks certain
I have a base controller for most of the controllers in my app like

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.