ASP.NET - storing classes in session variables - how does it work (memory)?

I read that you can store classes directly in a session variable i.e.

Session["var"] = myclass;

My question is how memory management works. Does it automatically serialize this in a client-side session?

Or does it store the data for the class instance in the server’s memory and simply contains the link in the session object?

+5
source share
4 answers

ASP.Net will store your object in a staticnested dictionary in memory on the server.
Then it sends a cookie to the client with the session ID.

, , ASP.Net , , , .

( , SQL Server - )

+12

, . , - . SQL Server . .

.

+5

, ASP.NET. , . , , ( ).

, cookie, , -, , , , , .

ASP.NET ,

+1

. , .

, SQL SERVER Database. , , , .

Your default session lasts 20 minutes. You can change this in the web.config file as you wish. But after this time, the Garbage collection will delete it from memory.

+1
source

All Articles