AspNet 20 session stored in Sql

Sometimes it is preferable to store the session of asp.net in sql, I prefer to use a distinct database for each application, the command to create such database is

aspnet_regsql.exe -S localhost\isntancename -U sa -P sapwd -d databasename -ssadd -sstype c

Notice the use of –sstype c parameter that forces the script to create a custom database, without that argument the scritp does not permit you to use a custom database name to store the session. In web.config you should also state that you want to use a custom type sql database with allowCustomSqlDatabase=”true”.

<sessionState
timeout=“60“
allowCustomSqlDatabase=“true“
mode=“SQLServer“
sqlConnectionString=“Database=EasyCVSessionStore;Server=localhost\SQL2000;…/>

Also avoid to copy session database around, and recreate always with aspnet_regsql.exe, it avoid you some headache.

Alk.