w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result

The problem is that you're putting something in session that isn't serializable (as you suspect).

Since you've marked your own classes as Serializable there are a couple of likely possibilities:

  1. You've inherited from something that isn't Serializable (so marking your inherited class Serializable won't help).

  2. You're attempting to store something in session that isn't one of your classes, and isn't serializable, most likely a framework class. Common examples might be EntitySet, DataTable or Dictionary<>.

Also the exact class that is causing the problem should be clear from the full exception info.

For example the following is in the error message shown in the question I've linked to:

[SerializationException: Type 'Gebruiker' in Assembly
'App_Code.qzuhycmn, Version=, Culture=neutral, PublicKeyToken=null'
is not marked as serializable.]

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.