ASP storage use cases
So I'm aware there are several places to store data, which I will list as follows:
Serverside (application):
Sessionstate
AddSingleton
AddScoped
Clientside:
Cookies
LocalStorage
SessionStorage
I was wondering where specifically each of these 6 would be used, particularly for sessionstate, singletons and scoped?
3 Replies
These are things to handle user/object state of the web application, none of those intended to store data in manner of database
Each can be used for different purposes, depends on what to achieve
for definitions, you can google them separately
Singleton and Scoped are used to define creation of object instances (Classes, Helpers, Services etc mostly through dependency injection)
Cookies and Sessions are the concepts of authentication that are where the state of token/sessionId is stored, managed
So sessionstate (on the app) and sessionstorage/localstorage (on the browser) are meant to be interlinked somehow?
Because they are very different storage locations with different access methods
I'm actually very confused on what sessionstate is meant to be used for
It's not stored to the browser, and it only holds strings and int32
Local browser store isn’t tamper proof btw
Use with caution
Strings can contain representations of other data types. But session can get tricky in a clustered environment; how do you synch session changes?