I would like to keep a persistent list of key/value pairs between the controller and views throughout multiple calls back to the controller accumulating the pairs as I go along.
I have tried looking into using the TempData[] technique, but this seems to become excessively complex when working with a list or collection of paired data.
Normally we store simple values (such as strings, numeric etc) in TempData
. To store complex types using TempData
, we could serialize it to a string-based format first.
If you do not want to do additional serialization with using TempData
, to persistent list of key/value pairs data across requests, you can try to store these data in session.
For more information about state management in ASP.NET Core, you can check this official doc:
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/app-state?view=aspnetcore-5.0
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…