Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.net session storage

Are there any pre-conditions before storing any objects in session state. I mean when will I not be able to insert an object in session state. This was an interview question that was asked to me. What could be the possible reason for not being able to store an object in session state?

like image 393
sly_Chandan Avatar asked Aug 30 '11 12:08

sly_Chandan


2 Answers

Here are some that should be considered:

  • If it has more session data, then more memory is consumed on the web server, and that can affect performance.

  • It won't work in web garden mode, because in that mode multiple aspnet_wp.exe will be running on the same machine.

  • And if the appdomain or worker process (aspnet_wp.exe) restart/recycles very often then its not a good idea to use it

and it is gathered from here ... hope it answer your query ...

like image 110
Safran Ali Avatar answered Oct 18 '22 01:10

Safran Ali


There are places in the asp.net page request life-cycle that you do not have access to the session state yet due to the lack of a valid user session such as Application_Authorize where we do not have an authenticated user yet, so Session will be null. The actual implementation of the Session store shouldn't really be a concern, neither should how the data is serialized.

like image 44
Peter Short Avatar answered Oct 18 '22 03:10

Peter Short