09.16.07
An Overview of the Session Object in ASP .NET 2.0
The article focuses on the various types of session objects in ASP.net 2.0. It also provides an insight into the new advanced features incorporated in this version. In the classic ASP version, it did not have had any reliable Session Objects as it was held in process to the IIS process. In this design, any IIS crash would have rendered the Session Object also useless. So, for programmers, in the classic version, it wasn’t possible to store important data in the Session Object such as client login. The latest ASP .NET 2.0 comes with new added features that make the Session Objects more robust and reliable.
There are 3 main types of storage providers available in ASP.net 2.0 (classic version had only one) - InProcess session state store, State server session store, and SQL Session state store.
If you need to modify the session state as per your requirements, you will need to make changes in the web.config file
<configuration>
<system.web>
<sessionState mode = “Off | Inproc | stateserver | SQLserver | custom”/>
</system.web>
</configuration>
InProcess Session State Storing Process
Used in classic ASP, you can able to stores the sessions in ASP .net cache memory. This is the default ASP.net 2.0 session provider. This is the fastest and most common session state in ASP .net 2.0. The data and the session state key are stored inside to the memory, hence the process is fastest among the all other session object provider.
InProcess session state works in one web server only. If you have multiple processor web servers, you have to assign the process to every processor. In this session state used only one server. When you request redirect to another processor, session state will be lost.
State Server Session Storing Process
You want to start the service manually from the Service Manager because the state service is not commenced by default. In order to start it manually, open the Service Manager and find out the ASP.NET state Service server or run it from command line. This process session is stored in aspnet_state.exe file which run as window service.
You can also run manually from the command line:
net start aspnet_state
By default, the State Service listens to port 42424. However, the port can be varied at register key. Your web.config file code should be changed into:
<sessionState mode = “StateServer”
stateConnectionString = “tcpip=127.0.0.1:42424”/>
One can run the State Server in his local web server machine or in another machine. However, before running the StateServer on another machine, ensure that the port is open or not. This can be easily verified by running the telnet command:
telnet 192.168.6.1 42424
You will get the reply if the port is open.
SQL Session State
Now you come to know the session should be stored in state server and memory. In process session offer speed and state server offer resilience and SQL session offer the reliability with speed. Store the objects in a serialized way; you fetch the data as immediately.
Scriptycan is a great software repository featuring both free and commercial ASP .NET scripts and applications for developers and programmers.