Things good to know about SQL State Server
While installing a SQL State Server last week, I came across a few things worth sharing about the installation and use of SQL State Server.
Finding a good tutorial
There are lots of tutorials out there on how to install SQL State Server but most of them are not great. To do a basic installation you only need this MSDN documentation on how to run the Aspnet_regsql.exe tool and edit your web.config.
All the objects in Session need to be serializable
If you try to store an object in Session which isn’t marked as serializible an HttpException will get thrown with following message.
Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.
Marking your classes with the Serializible attribute shouldn’t be a problem. Be careful when storing WebControls in Session though, most of these aren’t marked as serializible!
Error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
Use the same machinekey on multiple servers
To make the SQL State Server work across servers hosting the same application, you need to make sure the machineKey element in the machine.config is identical.
Redundancy options are limited
In SQLServer mode, you can configure several computers running SQL Server to work as a failover cluster, which is two or more identical computers running SQL Server that store data for a single database. If one computer running SQL Server fails, another server in the cluster can take over and serve requests without session-data loss.