This is also called Out-Proc session mode. StateServer uses a stand-alone Windows Services, which is Independent to IIS and can also run on a separate server. This session state is totally managed byaspnet_state.exe. This server may runs on the same system, but it's out side of that main application domain where your web application is running. This allow if you restart your asp.net process restarted your session data will be alive. This approaches has several disadvantages due to the overhead of serialization and de-serialization, its also increases the cost of data access because of every time when user retrieves session data, our application hits a different process.
In StateServer the Session data is stored in a separate Server which is Independent to IIS and Its handled by aspnet_state.exe. This process is run as windows Services. you can start this service from windows MMC or from command prompt.
By default "Startup Type" of ASP.NET state service is set to manual, we have to set it as "Automatic" startup type.
from command from just typing "net start aspnet_state". By default this services listen TCP Port42424 , but we can change the port from registry editor as given in below picture
Now have a look on the web.config configuration for StateServer Setting. For State Server Setting we need have to specify the stateConnectionString. This will identify the system that is running state server. By default stateConnectionString used ip as 127.0.0.1 (localhost) and Port 42424.
When we are using StateServer, we can configure stateNetworkTimeOut attributes to specify the maximum number of seconds to wait for the service to respond before canceling the request. Default time is 10 seconds
For using StateServer, the object which we are going to store that should be serialized and at the time of retrieving we need to De-Serialize. I have described it with an Example.
0 comments:
Post a Comment