Description:
ASP.NET session state provides several storage options for session variable, Those are
1. InProc (Default mode)
2. StateServer
3. SQLServer
4. CustomMode
5. Off Mode (Session state is disabled for the web application)
InProc Mode:
State Server Mode:
SQL Server Mode:
Note: Since both the State Server and SQL Server mode session state is stored our of process , it should be ensured that the data you are storing in session are serializable. while this restriction is not applicable to the InProc session mode, it allows all kind of object for storage.
Custom Mode:
In this mode session data is stored using the custom session state provides and provides complete control over session. It allows to store data on different data sources like oracle, Access, MySql etc.
As we know HTTP is a state less protocol, this means every request in the web server is treated as a independent request. The web server has no knowledge of values that are used in previous request. ASP.NET session state provides its solution, It helps to identify requests from the same browser for a configured time period and provides the way to persists the values and variables.
So a session is defined as the period of time that a unique user interacts with a web application. When the user first try to access a web page the session is created. ASP.NET maintains session state by providing the client a unique id called SessionID and which was either stored in a cookie by default or passed through the URL. Then after that the session cookie travels along with the page on every request to the server. ASP.NET uses this key to identify the user and its session information. Session variables are stored in a SessionStateItemCollection object and exposes by the HttpContext.Session property.
ASP.NET session state provides several storage options for session variable, Those are
1. InProc (Default mode)
2. StateServer
3. SQLServer
4. CustomMode
5. Off Mode (Session state is disabled for the web application)
InProc Mode:
This is the default mode for storing session data. In this mode session data and variables are stored inside the memory of the local web server. It works faster than the other modes as data is stored in the same process with the application and also provides the Session_OnEnd event which is not available by other session state modes. One of the disadvantage of using this mode is that it loses all the session information when the application restarts as both are reside in the same process and another is it does not support the web firm situations.
State Server Mode:
In this mode session data is stored in a separate process called ASP.NET state server. In this mode it is ensured that the session state preserved even if the web application restarts or in the case of web firm situations.
SQL Server Mode:
This mode uses the SQL Server to store the session state information. Like the State Server mode this mode also ensures that the session data is available even if the web application restarts or in web firms. This is the most reliable mode of storing the session even if the sql server restarts the data preserved (if the data is configured to be stored in user database not in tempDB). And the disadvantage is it is the slowest in storing and retrieving among all the available modes.
Note: Since both the State Server and SQL Server mode session state is stored our of process , it should be ensured that the data you are storing in session are serializable. while this restriction is not applicable to the InProc session mode, it allows all kind of object for storage.
Custom Mode:
In this mode session data is stored using the custom session state provides and provides complete control over session. It allows to store data on different data sources like oracle, Access, MySql etc.
This is a nice article..
ReplyDeleteIts easy to understand ..
And this article is using to learn something about it..
c#, dot.net, php tutorial, Ms sql server
Thanks a lot..!
ri80