开发者

Persisting the List and Getting it back in Controllers action

开发者 https://www.devze.com 2023-02-04 15:54 出处:网络
I have an action whe开发者_StackOverflowre I get the list from the database and pass it to the view. Now, I want that when I fire another action I can somehow get hold of that list (List). How can I d

I have an action whe开发者_StackOverflowre I get the list from the database and pass it to the view. Now, I want that when I fire another action I can somehow get hold of that list (List). How can I do that since ViewData and the TempData is erased on each request.


TempData does get erased on each request, but there is nothing stopping you from setting it again so that it will be there for the next request as well.

That said, in this case your problem is really about avoiding repeated queries, so it might better to look at using a more generic cache rather than doing something with tempdata or session in each action.

0

精彩评论

暂无评论...
验证码 换一张
取 消