ASP.NET State Server 服務 sessionState

在發佈ASP.NET網站的時候,出現state server錯誤:
Server Error in '/' Application.
--------------------------------------------------------------------------------
  Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same. If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection. 
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  Exception Details: System.Web.HttpException: Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same. If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection.
出現這種錯誤的緣由,通常能夠概括爲一下幾點:
一、ASP.NET State Server 服務關閉了,開啓便可。
     ASP.NET State Server服務默認是手動開啓的, 因此不少時候在服務器重啓後,ASP.NET State Server 服務實際上是中止狀態的,最好將該服務設成自動啓動。
二、HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection的值不爲1,確保服務器能接受遠程請求。
    AllowRemoteConnection 的鍵值設置成「1」後,意味着容許遠程電腦的鏈接,也就是說只要知道你的服務端口,就可享用你的ASP.NET State Service,即把 Session 存放在服務器進程內,但這樣會致使安全性減弱。
三、42424端口被其餘程序佔用或者沒有開啓,由於42424端口是將session存在服務器進程必須的。
四、設成StateServer 後,必需要有對應的stateConnectionString 。
     Web.config中<sessionState> 節點內容應該設置成相似下面內容:
     <sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="300"/>web

相關文章
相關標籤/搜索