Which is the best method to temporary hold and access collection of data between one more controllers?
For example, view1.cshtml contain a grid with the following data items:
--------------------
Name | Address | Age
--------------------
aa | ad1 | 11
--------------------
bb | ad2 | 22
-------------------
cc | ad3 | 33
--------------------
and if a user selected first 2 rows, then the selected row items needs to be displayed in a grid on another another view named view2.cshtml. The user can go back to first view again and if select a new row item , then I want to to append the selected item too to the grid displayed on the second view.
I've tried ViewBag and TempData to temporarily store the data. But unfortunately the data getting cleared on sometimes. Which is the best option to solve this situation?
I would use Session to store the collection of data since you need to pass data between one or more controllers.
Save:
Get: