Session State Management in Asp.Net:-
Asp.Net session state management has built in functionality that stores the data accordingly to the session.
Stateless Protocol:- Asp.net session state management automatically erase the data if the client browser does not revisit the application with in a specified time.
Session State Modes:-
- InProcess
- State Server
- SQL Server
InProcess:-
In this mode Session, state is stored in the memory space of the Aspnet_wp.exe process. This is the default setting
Advantages:-
- It is default method.
- It is simplest method because no configurations are required as a part of development.
- It is fastest method.
Disadvantages:-
- Session information is lost if the Asp.net_wp.exe process is restarted.
- It is not suitable for web forms.
State Server:-
Session information is stored in a separate state server process. The worker processor will communicate with the state server and retrieve the session information.
Steps to configure the State Server:-
- StateServer mode session data is stored in a different process so you must ensure that
your objects are serializable. - <machineKey> elements in Web.config should be identical across all servers. So this
ensures that encryption format is same across all computers. - IIS metabase (\LM\W3SVC\2) must be identical across all servers in that farm.
Advantages:-
Tolerance of the worker process being recycled.
it is suitable for use on Web forms.
Disadvantages:-
- Slightly slower and more resources demanding then In process, because there is no extra level communication is required between process.
- State information is stored in a single server.
SQL Server:-
Session information stored in a SQL Server data base. The worker process will communicate with the SQL Server to retrieve the session information.
Steps to configure the SQL Server:-
- SQLSERVER mode session data is stored in a different process so you must ensure that
your objects are serializable. - IIS metabase (\LM\W3SVC\2) must be identical across all servers in that farm.
- By default Session objects are stored in Tempdb, you can configure it store outside
- TempDB by running Microsoft provided SQL script.
Advantages:-
Tolerance of worker process crashes.
Suitable for Web forms.
Can be configured to work in a fail over clusters.
Disadvantages:-
Required SQL Server.
It is slower than both InProcess & State Server.
Complex to set up.
No comments :
Post a Comment