Archive for November 7th, 2008

Setting up session state database on sql server

Just a quick reminder for myself- if you have a fresh sql database that you want to install the default asp.net session database on for use by your applications, the command line value you want is;

aspnet_regsql.exe -S <server> -U <dbuser> -P <password> -ssadd -sstype p

To then set your application up to use sql server for state maintenance, add the following to your web.config file;

ASP.net 1.1.4x:

Under the <system.web> section

<sessionState
mode="SQLServer"
timeout="20"
cookieless="false"
sqlConnectionString="Data Source=WEBSQL; User
Id=xxx;Password=xxx;"”
/>

ASP.net 2.0.5x

Again under the <system.web> section (not using the standard state database name)

<sessionState
mode="SQLServer"
allowCustomSqlDatabase="true"
sqlConnectionString="Data Source=WebSQL;
database=ASPStateDotNet2;user id=xxx;password=xxx"
cookieless="false"
timeout="40"
/>

We had a 1.1 session store already setup and setup the .net 2 seession store on the same server under a different database name. To do this just append a “-d ” parameter to the end of the command line.

No Comments