Configuring a SQL Server to store session state data

To configure your session state database Microsoft has created a command line tool which will create the database for you. You can find the tool in the .NET framework folder. You must use the tool which corresponds to the framework version you are using. In my case I am using .NET 4.0 64 bit.

1. Browse to this location:

C:\Windows\system32>cd  C:\Windows\Microsoft.NET\Framework64\v4.0.30319

2. Run these commands substituting ‘ServerName’ for the SQL server you wish to create the database on:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regsql.exe -S ServerName -E -ssadd -sstype p
Microsoft (R) ASP.NET SQL Registration Tool version 4.0.30319.33440
Administrative utility to install and uninstall ASP.NET features on a SQL server
.
Copyright (C) Microsoft Corporation. All rights reserved.

Start adding session state.

..

Finished.

3. You Should now see a new database appear on the SQL Server

ASP STATE

Once you have the database in place you can configure IIS to save the sessions in the database.

The Development team will need to update the web.config file to use the SQL server:

Using default security:
<sessionstate mode="SQLServer" timeout="20" allowcustomsqldatabase="true" 
sqlconnectionstring="Data Source=Server;User ID=UserID;Password=Password;" 
cookieless="false">

Using Windows authentication:
<sessionstate mode="SQLServer" timeout="20" allowcustomsqldatabase="true" 
sqlconnectionstring="Data Source=Server;Integrated-Security=SSPI;" 
cookieless="false">
Advertisements
Tagged with: , , ,
Posted in SQL Server
2 comments on “Configuring a SQL Server to store session state data
  1. Chase says:

    It’s hard to find your articles in google. I found it on 12 spot,
    you should build quality backlinks , it will help you to rank to google top 10.
    I know how to help you, just search in google – k2 seo tips and
    tricks

  2. Mary says:

    This article help me. Thanks a lot!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: