hanssens / localstorage

LocalStorage for .NET - A simple and lightweight tool for persisting data in dotnet (core) apps.
MIT License
74 stars 17 forks source link

Passing Information Between Controllers #35

Open davidbuckleyni opened 4 years ago

davidbuckleyni commented 4 years ago

Hi i stumbled uppon your localstorage looks a great solution I just need to pass a cased Id from one controller to another was trying to use session in asp.net core but it was loosing the value.

How do I use localstorage between controllers without deleting the previous instance data is it easy to do.

hanssens commented 3 years ago

Stating the obvious, but please be aware that the lib is not built for multi-concurrency or distributed scenarios. That being said, the limitation of using localstorage between controllers is that you use it read-only + re-use the same filename (and use Persist() to store it to disk).

One option to accomplish would be to register LocalStorage as a singleton. Alternatively, if you reuse the same file between controllers. That is, as long as you're using it only to read between different operations. Write, as in concurrent writes, is not supported.

In the latest v2.1.0 release I've started working on the 'read-only' mode. This is still a work in progress, but theoretically if you have an existing localstorage file that you use as 'read-only' this might solve your problem.