如题我在Web中使用State Server来保存用户的Session我的Windows服务/应用程序怎么操作State Server里的指定用户的Session?在网上找了N久,没找到相关的文章,200分求代码,谢

解决方案 »

  1.   

    2006年做过一个在SQL Server中存储Session的项目,现在给忘记了。
      

  2.   

    session存数据库里也是不错的思路~
      

  3.   

    How to decide which method to use to store session information
    State Server
    With the "State Server" model session information is stored in a separate "state server" process. The worker process (aspnet_wp.exe) will communicate with the State Server (aspnet_state.exe) to store and retrieve session information.If you are working in an environment where there is more than one web server then another key difference from the in-process model is that all the servers should be configured to talk to the same state server process. This is a configuration issue and it would be easy to (wrongly) configure a web farm to use separate state server process on each server.Storing session information in the state server has the following advantages:It is tolerant of the worker process being recycled. For developers this has the advantage (or disadvantage!) that session information is maintained across compiles of the application. 
    It is suitable for use on web-farms. 
    and the following disadvantages:It is slightly slower and more resource demanding than the in-process model, because:
    there is an extra level of communication required between processes and 
    everything in the session needs to be serialized and de-serialized on each web request. 
    State information is stored on a single server - this is not an issue normally but might be if you need to avoid a single point of failure (in which case SQL Server is the route to go because it supports failover servers). 
    To configure to use the state server model requires the sessionState parameter in the web.config file to be updated:<sessionState
      mode="StateServer"
      stateConnectionString="tcpip=server1:42424"
      cookieless="false"
      timeout="20" />
    The default entry for stateConnectionString is "stateConnectionString="tcpip=127.0.0.1:42424", this is reasonable if the state server is on the same server (The IP address 127.0.0.1 is by definition the local machine). If however you are running in a web-server environment then it is vitally important that you set the server name, so substitute the name of a server for "server1" in the above example. Otherwise each server will communicate with the state server process running locally and session information will not be shared between servers.You also need to ensure that the state server is running on the chosen server. Do this by looking at the services on the server and ensure that "ASP.NET State Service" is started and set to "Automatic" start-up.
      

  4.   

    你可以在网上搜索一下web.config里面的说明,我曾看到过有一篇文章专门讲述SessionState.
      

  5.   

    给点提示是不是有帮助
    Session可以存储【用户名+特殊字符+SessionID】
    这样在服务器段,State Server不懂,
    绑顶一下
      

  6.   

    State Server??还是帮你顶上吧.