Last post Feb 19, 2016 12:21 AM by claudia888
Feb 14, 2016 09:21 PM|claudia888|LINK
Our company has an ASP.NET web application that was initially built in 2008, and it uses session variable extensively, and using "InProc".
Over the years we have added on a lot of features, many of them continue to use session state "InProc".
We are looking into the possibility of changing this to using SQL server to store session variables, as Scott Hanselman suggested here:
Our question is: is there a systematic way, that is simple and complete, that we can modify our application to make this transition?
Note: our application has both web forms and MVC code; we have dedicated servers, so we do plan to use a dedicated DB for this purpose.
Any suggestion/advice is appreciated.
Feb 15, 2016 06:07 AM|Candice Zhou|LINK
To use SQLServer mode, you must first be sure the ASP.NET session state database is installed on SQL Server. You can install the ASP.NET session state database using the Aspnet_regsql.exe tool.
To configure an ASP.NET application to use SQLServer mode, do the following in the application's Web.config file:
1) Set the mode attribute of the sessionState element to SQLServer.
2) Set the sqlConnectionString attribute to a connection string for your SQL Server database.
The following example shows a configuration setting for SQLServer mode where session state is stored on a SQL Server named "SampleSqlServer":
And for installing the Session State Database using the Aspnet_regsql.exe Tool, please see:
Feb 19, 2016 12:21 AM|claudia888|LINK
Thanks for your reply.
1 follow-up question: Our application uses a lot of session vars; most are simple types, but in some pages, the session vars are complex data types; such as an array, a list, or a data object from a view model.
How should we handle those, in terms of using SQL Server to store session vars?