How to configure SQL Server to manage ASP.NET sessions

我怕爱的太早我们不能终老 提交于 2019-12-18 07:22:29

问题


I need to know how to configure the .config to manage Session state in SQL Server


回答1:


First you need to create a Session database. In order to do this:

  1. Look for the aspnet_regsql.exe
  2. Run this command aspnet_regsql.exe -S [ServerName] -E -ssadd -sstype p

Where ServerName is your server name.

This will create this database ASPState

Now the configuration on the web.config

Add this sentence over

<sessionState allowCustomSqlDatabase="false" mode="SQLServer" sqlCommandTimeout="7200" sqlConnectionString="Server=SERVERNAME;User ID=User;Password=Password;" timeout="120" />

sqlCommandTimeout="7200" = 2hours and timeout="120" = 2hours

If you need more options regarding aspnet_regsql you can take a look HERE




回答2:


<configuration>
  <sessionstate 
      mode="stateserver"
      cookieless="false" 
      timeout="20" 
      sqlconnectionstring="data source=127.0.0.1;user id=<user id>;password=<password>"
      server="127.0.0.1" 
      port="42424" 
  />
</configuration>

Additional options here: http://msdn.microsoft.com/en-us/library/ms972429.aspx



来源:https://stackoverflow.com/questions/4880824/how-to-configure-sql-server-to-manage-asp-net-sessions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!