Friday, August 10, 2012

ASP.Net - Setting up the session store in SQL Server

1) Navigate to Visual Studio Tools > Visual Studio Command Prompt

2) Execute aspnet_regsql.exe -ssadd -sstype c -S [sqlservername]  -d [sqldatabasename]  -U [sqlusername]  -P [sqlpassword]

3) Add line to web.config 

sessionState mode="SQLServer" 
allowCustomSqlDatabase="true" 
sqlConnectionString="data source= [sqlservername];Initial Catalog=[sqldatabasename];user id= [sqlusername];password=[sqlpassword];" 
cookieless="false" 
timeout="900"

allowCustomSqlDatabase is required if you have configured a non standard database name.

[Edit] - 30th of August 2012

The [sessionState] attribute needs to be added in the [system.web] section of the web.config

References:

aspnet_regsql.exe - parameters;
http://msdn.microsoft.com/en-us/library/ms229862%28v=vs.80%29.aspx

No comments:

Post a Comment