close

 

建立存放Session專用資料庫

使用命令提示字元,進入.Net資料夾。如C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319

執行aspnet_regsql.exe -S 資料庫主機IP -U sa -P 密碼 -ssadd -sstype p

若要自定資料庫名稱,請使用

aspnet_regsql.exe -S 資料庫主機IP -U sa -P 密碼 -ssadd -sstype c -d 資料庫名稱

 

 

Web.config設定

<sessionState mode="SQLServer"

sqlConnectionString="data source=資料庫主機IP;user id=可存取帳號;password=密碼"

cookieless="false" timeout="20" />

若要指定資料庫,sqlConnectionString請使用

<sessionState mode="SQLServer" allowCustomSqlDatabase="true"

sqlConnectionString="data source=資料庫主機IP;database=資料庫名稱;user id=可存取帳號;password=密碼"

cookieless="false" timeout="20" />

 

 

IIS站台共用Session方法 (大推!!)

Reference: http://www.cnblogs.com/haoxue/archive/2010/10/11/asp_net_session_share.html

存放Session專用資料庫記得用獨立名稱,以免不相關站台誤用

修改預存程序dbo.TempGetAppID

SET @appName = LOWER(@appName)

LOWER(@appName)改成自己想要的名稱

Web.config設定對應的資料庫名稱

 

arrow
arrow
    全站熱搜

    deantsai 發表在 痞客邦 留言(0) 人氣()