开发者

Changing to SQL server for ASP.net session manangment

开发者_开发问答

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.

  1. 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
  2. Currently, I am saving the session as Sesssion.Contents["..."], how does this affect if I change it SQL server as session managment?
  3. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜