State Management

State Management

State Management

  • ASP.NET applications are hosted on a Web server and accessed using the stateless HTTP protocol
  • ASP.NET applications must implement state management themselves if it is needed

Server-side Session State

  • Maintained by a collection of user-defined session variables that are persistent during a user session
  • Variables are accessed using the Session collection
  • Variables are unique to each session instance
  • Variables can be destroyed after a defined time of inactivity even if the session does not end

Client-side Session State

  • Maintained by a cookie (default) or by encoding the session identifier (ID) in the URL
  • ASP.NET supports several modes for storing data related to session requests

Session State Modes

  • InProc mode (the default) stores the session state in memory on the Web server
  • StateServer mode stores session state in a separate process called the ASP.NET state service
    • Separate from the ASP.NET worker process or IIS application pool
    • Ensures session state is preserved if the Web application is restarted
    • Useful for making session state available to multiple Web servers in a Web farm
  • SQLServer mode stores session state in a SQL Server database
    • The ASP.NET session state database must be installed on SQL Server
    • Use the Aspnet_regsql.exe tool to install the ASP.NET session state database
    • Ensures session state is preserved if the Web application is restarted
    • Useful for making session state available to multiple Web servers in a Web farm
  • Custom mode supports the use of a custom session state store provider
    • Specify the provider type using an add sub-element
    • Use the type attribute to specify the provider's type name
    • Use the name attribute to specify the provider instance name
  • Off mode disables session state

Session State Mode Guidelines

  • Set cookieless to false for the SessionState setting in web.config because Sitecore does not support cookieless sessions
  • Web Forms for Marketers 2.3 (for CMS 6.5) has been optimized to work with SQLServer session state mode
Configuration Settings
  • <configuration>
    • <sitecore>
      • <system.web>
        • <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;user id=sa;password=" cookieless="false" timeout="20" />

Sources