How to Use Sessions in a Web Farm - ASP.Net
In a clustered web server, most of the time the hosts use load balancers. Such situations we can not use In Process Session variables to store our data across pages. In process works on the same thread of asp.net so it maintains in the server memory. If we use In Process we feel like our sessions get expired frequently. ASP gives us other 3 options to store our sessions. StateServer, SqlServer or custom. They are called out of process sessions. To save sessions in StateServer or Sqlserver we need our objects to be serialized. If we choose Linq To Sql the serialization of Entity classes will be more complex. The below steps can be adopt to overcome Stateserver,Sqlserver session issues 1). Make sure that we have decorate the entity classes with DataContract attribute 2). Or if you use VS, just right-click and set Serialization Unidirectional in properties 3). Helper methods to serialize using Memorystreams public static MemoryStream Serialize (T...