How to enable ASP.NET SQL Server Session for your web application

In ASP.NET, there are 3 different modes for storing session information:
 
    InProc
    StateServer
    SQLServer
 
We support both InProc and SQLServer session. By default, ASP.NET session is stored in-process (InProc). There are benefits and drawbacks for each method.

InProc mode offers the fastest performance because session is stored in the IIS Worker Process. The downside of InProc session is that sessions can be lost if the worker process is recycled for any reason.

SQL Server session on the other hands is slower than InProc, about 15-20% slower, but the session information remains persistent even after the worker process is recycled.

You should choose a state management mode that is appropriate for your application. For example, if losing session is not acceptable, you should consider using SQL Session rather than InProc.

To enable SQL Server Session
 
  - While not required, we recommend adding a new MS SQL database in the Site Tools section of Control Panel, dedicated for sessions storage only, to avoid potential conflicts (if you have a Basic account you will have to upgrade to a Max account to add a second database).
 
  - Create a support ticket to request an installation. Include the Database name and the version of ASP.NET you are using.
 
  - You will receive an email as soon as the Session State database schema is created.
 
  - Update your web.config file as follows:
 
< sessionState
  mode="SQLServer"
  allowCustomSqlDatabase = "true"
  sqlConnectionString="data Source=<SQLSERVERNAME>;database=<SQLDATABASENAME>;user id=<SQLUSER>;password=<SQLPASSWORD>"
    cookieless="false"
  timeout="15"
/>
 
Session information should be stored in your SQL database now.
 
If you run in to problems using this code, please post in our community forum. Technical support cannot assist with specific coding related issues.