Posts

Showing posts from December, 2010

Session Management Asp.Net

Please do comment if you find this infromation contradictory. We should always have a centralized location to manage all the session variables in our application. This way, it is really very easy for all the programmers working on the application to get to know about Session Information. This session information can be reused whereever needed. It's not a problem to store "objects" (as opposed to value-types like int) into Session. You could even say it's better to store objects than value-types, because those value-types need "boxing" and "unboxing". To achieve this purpose, we have used hashtables to be saved in a session. Every module can have its own hashtable to group all the common session information. The key/value pair of the hash can be exposed through public properties. For instance, below is the complete code of Session Management Class for only one variable in a hashtable. Sample VB.Net Code 1: Public Shared Property NHPActive