We observed this strange behavior while deploying our MVC application as an Azure-hosted service. When we store objects in session that are tagged with DataContractAttribute they don't get serialized properly via the DistributedCacheSessionStateStoreProvider. Essentially, what we discovered is that you cannot use DataContract on items that you store in the Azure Cache. The Azure Cache store will not provide you with any errors either, you just end up with the default object type with default values during retrieval. Any values that should have been stored are missing, but the default object is retrieved.
While troubleshooting this problem, we did not see this problem in any of the other Session Store providers. We verified InProc, ASP.NET State Server, SQL Server Session, and AppFabric Cache all work perfectly with classes tagged with DataContract. However, it seems Azure Cache uses NetDataContractSerializer which provides some limitations on what types can be stored and retrieved via its cache store.
Will this be fixed in future Azure Cache version, and why is it not listed publicly as a limitation of the Azure Cache? This costs us 3 days of troubleshooting until we pinpointed the root cause. Hopefully others will benefit from this post.
Yes, I think documentation request may be more appropriate:
DistributedCacheSessionStateStoreProvider does support DataContract attribute on type and as far as i am aware other providers don't support it. They support [Serializable].
Since you are saying that you are getting default values, are you sure you have adde [DataMemmber] to instance memeber that you want to serialize. Until members are tagged with [DataMemmber], they don't get serialized, while in Serializable, all instance memmbers of the class marked with "Serializable" attributed are by default serialized.
You can read more about datacontract here: