How can I use custom serialization with ASP.NET session state?

#1
For our cached objects, we use NamedCache.SetCustomSerialization() to set a custom serializer and deserializer to use for cached objects in place of BinaryFormatter.

We also use SossStoreProvider to store our session state objects. How can we tell SossStoreProvider to use the same custom serializer and deserializer that we use with the NamedCache API?
 

admin

Administrator
#1
ScaleOut ASP.NET Session provider uses Microsoft default BinaryFormatter serializer. If you're concerned about serialization cost (performance or size wise) for some of your objects stored in session, the best way to address it would be to implement ISerializable interface for these types so you can use a serializer of your choice for these objects.

You can read more about ISerializable interface here:
https://msdn.microsoft.com/en-us/library/system.runtime.serialization.iserializable(v=vs.110).aspx
 
#1
OK, we'll deal with that for now. However, we would like to request this as a future feature. The reasons why we feel that this should be possible are:
  • It allows us to decouple serialization from how we model something. For example, we might share a User object between an app and a website, but each might serialize these differently for different uses. We want to separate our shared descriptions of things from usage-specific serialization, which ISerializable makes difficult.
  • It allows us to re-use serialization logic we have already created. For example, our API and web app can already serialize objects in JSON, and we want to use the same serializer with our session state so that we don't have to maintain two serializers for the same object within the same application, and keep them synchronized to avoid bugs.
 
Top