asp.netsession-statestateserver

Asp.Net how to transfer session state to a State Server


I need to transfer session state of an Asp.Net application to a state server. Does any one have any experience about how to do it?

Thanks .


Solution

  • if you want to use SQL Server as session state server, put this snippet in your web.config:

    <sessionState
      mode="SQLServer"
      sqlConnectionString="data source=server;user id=uid;password=pwd"
      cookieless="false" timeout="20" />
    

    keep in mind that in order to have the Session Serialized to a State Server you should put in the Session only serializable objects, or you will get exceptions.

    We had this problem in the past and had to check everywhere in the code and make all objects stored in the session Serializable; for some classes it's easy for others is less.

    you can also read this article: Using SQL Server for ASP.Net session state or any other article you find online ;-)

    Edit: for the StateServer you should change the mode attribute in the web.config to the value: StateServer.

    also for this there are articles and examples and discussions also in SO:

    ASP.NET: Moving Session Out-of-Process with StateServer (Adventures in ASP.NET)

    Scaling up the ASP.NET session state server (SO)