Configuring ASP.NET website to use SQL Server 2005 for Session state

Today i was working on an application. The session breaks in between and when i was trying to find a problem and i found that ” if anti virus scan’s the website then the session will break it seems”. so thought of storing the session in sql server
and Here is the steps to follow

Step 1

Here is the code to add in web.config

< sessionState mode="SQLServer" sqlConnectionString="data source=#;UID=######;PWD=*******;" cookieless="false" timeout="20"/>

(no need to give DBname)

Step 2

Now we need to run the Install script (InstallPersistSqlState.sql) “Download here” on sql server. Download the Uninstall script here “Download here”

Step 3

After run the script. i got this error “Unable to use SQL Server because ASP.NET version 2.0 Session State is not installed on the SQL server. Please install ASP.NET Session State SQL Server version 2.0 or above.” when i run the website.

Later i found that we need to update the framework for the database . here is the command to run it

Go to command prompt and execute this

C:WINDOWSMicrosoft.NETFrameworkv2.0.50727>aspnet_regsql.exe -S -U ###### -P ******* -d ASPstate -ssadd -sstype c

Change the ##### to userid and ******* to password

after this it solved my problem and now my sessionstate is capture in sql server :).