Web Debug

Fix broken web applications, from servers to clients.

Troubleshoot asp.net session lost issues

ASP.NET session state supports several different storage options for session data. Each option is identified by a value in the SessionStateMode enumeration. The following list describes the available session state modes:

  • InProc mode, which stores session state in memory on the Web server. This is the default.
  • StateServer mode, which stores session state in a separate process called the ASP.NET state service. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.
  • SQLServer mode stores session state in a SQL Server database. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.
  • Custom mode, which enables you to specify a custom storage provider.
  • Off mode, which disables session state.


ASP.NET provides two events that help you manage user sessions: the SessionOnStart event, which is raised when a new session begins, and the SessionOnEnd event, which is raised when a session is abandoned or expires.

Note:

If the Global.asax file or Web.config file for an ASP.NET application is modified, the application will be restarted. If the current session-state mode is InProc, any values stored in application state or session state will be lost. Be aware that some anti-virus software can update the last-modified date and time of the Global.asax or Web.config file for an application. For information on setting the session state mode, see Session-State Modes.

To use StateServer mode in a Web farm, you must have the same encryption keys specified in the machineKey element of your Web configuration for all applications that are part of the Web farm. For information on how to create machine keys, see article 313091, "How to create keys by using Visual Basic .NET for use in Forms authentication," in the Microsoft Knowledge Base at http://support.microsoft.com.

Session-State Events

http://msdn.microsoft.com/en-us/library/ms178583.aspx

Detecting Session Timeout in ASP.NET 2.0 Web Applications

http://blogs.msdn.com/b/nikhiln/archive/2007/06/21/detecting-session-timeout-in-asp-net-2-0-web-applications.aspx

 

Session-State Modes

http://msdn.microsoft.com/en-us/library/ms178586.aspx

Configure a State Server to Maintain Session State (IIS 7)

http://technet.microsoft.com/en-us/library/cc732412(v=WS.10).aspx

Generate a Machine Key for a Web Farm (IIS 7)

http://technet.microsoft.com/en-us/library/cc731979(v=ws.10).aspx

HOW TO: Configure SQL Server to Store ASP.NET Session State

http://support.microsoft.com/kb/317604

Session State Management

http://blogs.msdn.com/b/paraga/archive/2005/12/10/502345.aspx

Fork me on GitHub