Friday, 4 July 2014

How to configure SQL Server Session State with Custom Database

There are two steps got to follow to enable the SQL Server Session state to work

1. Configuring the database to support the SQL Server Session state.
2. Configuring your application to use SQL Server Session state.

1. Configuring the database to support the SQL Server Session state.
.Net framework has a tool aspnet_regsql which you can use to add the table and stored procedure to support SQL Server Session state. You can find this tool in the following folder.
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ aspnet_regsql.exe
You can run this exe from window command prompt or you can directly run from SDK Command prompt.
Executing the following command enables SQL Server Session state for a database server named local and store it in a custom database called CustomSessionDB.
aspnet_regsql -C "Data Source=local;User Id=sa; Password=Sql2005" -ssadd -sstype c -d CustomSessionDB
Executing this command creates a new database named CustomSessionDB that contains both the tables and stored procedures for storing Session state.

2. Configuring your application to use SQL Server Session state.
To Configuring your application to use SQL Server Session state change the session state session as follows:
<sessionState mode=" SQLServer" sqlConnectionString="data source=local;user id=sa;password=Sql2005;database=CustomSessionDB" timeout="30" allowCustomSqlDatabase ="true" />


No comments:

Post a Comment