I have asp.net web site uses "inproc" as session manangment. Now, I am looking at the option to store the sessions in SQL server. I looked at the some online articles that I have to use "InstallSqlState.sql or InstallPersistSqlState.sql" to create the session database on the sql server. Here are my questions.
- Do I have to use the script or can i just create a database manually (using SQL management studio to create one) and just make sure I update the exact database information on the web.config
- Currently, I am saving the session as Sesssion.Contents["..."], how does this affect if I change it SQL server as session managment?
- Is using SQL going to be make the site running slow?
Thanks.
I would recommend you using the aspnet_regsql.exe utility (part of the .NET framework) which will create the necessary databases and tables. It can be run from a remote machine as well, not necessary from the SQL Server. For example:
aspnet_regsql.exe -S SomeSqlServer -E -ssadd -sstype p
Once you the ASPState database is created on the target SQL Server simply modify your web.config file to specify that you want to use a SQL Server for Sessions:
<sessionState
mode="SQLServer"
sqlConnectionString="Data Source=SomeSqlServer;Initial Catalog=AspSate;User Id=asp;Password=secret;"
/>
You might need to create a user which is authorized to access this database. No changes are necessary to your code.
精彩评论