Storing global informations RRS feed

  • Question

  • User420281980 posted


    I need to store global information somewhere (such as a selected language) for the current connection.

    I will give an example:

    The first connection(for example a user with google chrome) selects language English. I need to store this information "somewhere".

    The second connection (for example a user with microsoft edge) selects language French. I need to store this information "somewhere".

    How is it handled in ASP NET Core?

    I thought I could use static variables, but I'm not sure. Does each connection have its own static variables? Or are static variables shared for all connections?

    Sorry for this question, I am a beginner in ASP Net Core.

    Wednesday, March 31, 2021 1:25 PM

All replies

  • User753101303 posted


    Yes static variables are shared by all users : a  web app is basically a single applicarion used by multiple users at the same time.

    ASP.NET Core uses https://dotnetcoretutorials.com/2017/06/22/request-culture-asp-net-core/ to initialize the culture for each request based on the first source (allowing for example to take a user overide from the querystring or the browser default for the very first request).

    Another common option is to have the culture being part of the route ie using site.com/en-us or site.com/fr-fr

    Wednesday, March 31, 2021 1:40 PM
  • User420281980 posted


    thank you, but this example with language is only example.

    I would like to know how information for individual users is generally stored in ASP Net Core.  Static variables I can not use. What can I use?

    I store information "Info1" for user "User1", then I store "Info2" for user "User2" etc.

    I suppose it can be solved in ASP Net Core

    Wednesday, March 31, 2021 1:59 PM
  • User475983607 posted

    I think it is important to understand that web sites are stateless regardless of the framework or platform.  .NET 5 comes with many state management APIs.  The first step is to learn what features are available and what problem each API solves.


    I store information "Info1" for user "User1", then I store "Info2" for user "User2" etc.

    User scoped data is typically stored/cached in a cookie, database, or session.  You might use all three or two or one.  

    Wednesday, March 31, 2021 2:32 PM
  • User420281980 posted

    Thank you very much.

    I will study your link.

    Thursday, April 1, 2021 8:34 AM