I have some information about a user I need to store and access in an ASP.NET MVC 5 application. Here are some of the things that I will need to store/access:

  • Theme choice
  • If they want to show panel bar navigation
  • If they want to show menu bar navigation
  • If they want to hide unauthorized links
  • etc.

I am trying to figure out what is an efficient way of doing this. I could store the user specific information in a database. Then use a view model and pass the user specific information along with the other data the page needs. Doing so would cause me to query the database on each new page load.

Another option is to use session state. But in reading up on it I see a lot of people saying it is problematic and should be avoided whenever possible.

Is there another way of handling user specific information that I am missing?

2 Answers 2


You may consider a combining your options: Keep the user info in the database for long-term persistence but only query at login (or whatever is appropriate). Then cache this in Session, cookies, or some other client-side local storage to avoid additional queries.


In many web applications, it would be considered very normal to store this information in the database and pass it along as you suggest. That's the approach I would take.

If for some reason you don't already have a database, you could consider stuffing this sort of preference into cookies. That's assuming the amount of data is small, losing it doesn't matter much, and there's nothing security or privilege-related in there. Only consider cookies if losing the data (user wiped the cookies) doesn't cause any lasting harm.

  • I do have a database and will need to pull information from it for most pages. Adding the user specific information would just add more to retrieve. Do you use a ViewModel to pull the information with the data you need for the page? Use inheritance, having all viewmodels inherit the user specific class?
    – Linger
    Sep 23, 2016 at 16:37
  • I plan on extending the IdentityUser class to include the user specific information. Is this recommended, or should I create another table and link via primary/foreign keys?
    – Linger
    Sep 23, 2016 at 16:41
  • @Linger why don't you just pass these options as session variables? This way you only need to query the database once a user logs in or changes a setting, not on every page reload. Edit: nvm, just saw Jasens answer.
    – Broco
    Sep 23, 2016 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.