InProc (the session state is stored in the memory space of the Aspnet_wp.exe process but the session information is lost when IIS reboots), StateServer (the Session state is serialized and stored in a separate process call Viewstate is an object in .NET that automatically persists control setting values across the multiple requests for the same page and it is internally maintained as a hidden field on the web page though its hashed for security reasons.
Ways to manage state in Asp.Net are:
- Using Session and Application objects to cache information.
- Using Memory and Disk Cookies to preserve information.
- Using hidden input fields or the URL -embedded information to pass information from one page to another.
- Using the ViewState property of the page to set and retrieve information stored in a StateBag object.
- Using SQL Server to store state information.
Application_start gets fired when an application receive the very first request.
Session_start gets fired for each of the user session.
Session – The session object is used to store the data specific to a user for the entire length of a user’s visit to a website. Below is a code that shows usage of the session object in ASP.NET …
//InitialPage.aspx stores the user’s credentials in Session state
Session(“UserName”) = txtUserName.Text;
//DestinationPage.aspx gets the user’s name from Session state
String sString = Session(“UserName”).ToString();
The global.asax file handles Session and Application events.
Session object store information between HTTP requests for a particular user, while application object are global across users.
session is a object that store information between http request for a paticular user. ->But application object are global for each user