Tuesday, January 24, 2012

how can session information/data be stored using a SQL server?


At work we use an Oracle 9i db to store our session info by removing the standard session provided by .NET and forcing our own session implementation in the web.config file.
So to answer your question, in order to store ASP.NET session information inside SQL Server you must:
1) Have SQL Server version 7 or 2000 installed.
2) Execute the following script using SQL Server’s Query Analyzer, which creates the database that ASP.NET uses to store Session:
\%winroot%\Microsoft.NET\Framework\versionNum\InstallSqlState.sql
3. Modify the web.config file appropriately (where the connectionString attribute denotes the connection string that should be used to open the database):
<sessionState mode="SQLServer" sqlConnectionString=
"data source=127.0.0.1;user sa;password=" />
Storing Session inside SQL Server is the most durable option, as information persists even if the machine crashes. This is the slowest option of the three, however, because session data must be accessed from disk rather than directly from memory, a process thousands of times slower. Note that as with the Windows Service option, you can point ASP.NET to a Session store on a different machine, which is also appropriate in Web farm settings.

No comments :

Post a Comment