Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add List<string> in Session state

Tags:

c#

list

asp.net

Is there a way to add List in session? or any other way to pass the values of List in another page?

like image 921
nhoyti Avatar asked Jun 14 '10 06:06

nhoyti


People also ask

How do I store a list in session?

Yes, you can store any object (I assume you are using ASP.NET with default settings, which is in-process session state): Session["test"] = myList; You should cast it back to the original type for use: var list = (List<int>)Session["test"]; // list.

How can store data in session in core in asp net?

Session is a feature in ASP.NET Core that enables us to save/store the user data. Session stores the data in the dictionary on the Server and SessionId is used as a key. The SessionId is stored on the client at cookie. The SessionId cookie is sent with every request.


1 Answers

List<string> ast = new List<string>();
        ast.Add("asdas!");
        Session["stringList"] = ast;
        List<string> bst = (List<string>)Session["stringList"];
like image 117
Chinjoo Avatar answered Sep 28 '22 07:09

Chinjoo