How to retrieve a generic list from session?

前端 未结 5 2161
[愿得一人]
[愿得一人] 2021-02-09 19:12

I have a list that I put in session:

Session.Add(\"SessionList\", mylist);

How to retrieve it back from the session?

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-09 19:35

    Like below

     var list  = Session["SessionList"] as List;
    

    OR also you can cast like below

    var list = (List)Session["SessionList"];
    

提交回复
热议问题