user2070369
user2070369

Reputation: 4128

Sessions can't store serialized objects?

I'm trying to migrate a MVC3 Project to a MVC6, I've sorted out most of the obstacles but now I have a problem with sessions, I'm using "Microsoft.AspNet.Session": "1.0.0-beta4", and I can add strings and ints with no problem, but looks like I cannot add objects, only byte arrays (byte[]), so, how can I add a serialized object to sessions in MVC6?

Thanks.

Upvotes: 0

Views: 629

Answers (1)

user2070369
user2070369

Reputation: 4128

OK, looks like you have to manually serialize the object to a byte array with the BinaryFormatter and then add it, to deserialize it is the same but in reverse, get the byte array an deserialized to the object, also with a BynaryFormatter.

Upvotes: 1

Related Questions