views:

93

answers:

5

In an ASP.NET application you can store pretty much anything in the Session as long as you can handle the cost. What is the intended usage and what is most frowned upon when using the Session to store data?

A: 

Check out this question/answers.

Aaron Daniels
A: 

I like to use the session to hold keys, or indices into server-side data that doesn't need to be persisted between pages. That is lighter weight than persisting the whole object(s)

John Weldon
A: 

As of ASP.NET MVC2 TempData is stored in the session.

Some uses of it are described here: ASP.NET MVC - TempData - Good or bad practice and here Tempdata Improvements.

R0MANARMY
A: 

Session are used to persist information for each client.

Everytime a new client establishes a connection asp.net starts a new session for the newly connected client. You might want to keep some information persistent to current session of the client and display information on perform some operation based on his/her session information.

this. __curious_geek
+1  A: 

Any user specific data that has to be persistent across various pages of an application to the logged in user can stored in a session. The objects to be stored in Session need to be serializable.

Usually, it is recommended that the session should be used a little sparingly, because with an increase in number of concurrent users,the load on server memory increases and at one point, it recycles the memory causing all session data to be dumped. This causes a premature timeout of the session.

Srikanth Venugopalan