You can quickly get a βsnapshotβ of the current session objects using the following code (C #):
BinaryFormatter b = new BinaryFormatter(); StringBuilder debug = new StringBuilder(); MemoryStream m; foreach (String s in Session.Keys) { // try to serialize the object var obj = Session[s]; if (obj != null) { m = new MemoryStream(); try { b.Serialize(m, obj); debug.AppendFormat("{0}: {1} bytes\n", s, m.Length); } catch (Exception ex) { debug.AppendFormat("ERROR: {0}, Message: {1}\n", s, ex.Message); } } }
Then display the string "debug" in your favorite text container.
This is useful because simply switching to State Manager / SQL Server will really tell you that it cannot be serialized, but it will stop at the first non-serializable object. He also will not tell you which key "owns" this object.
Code adapted from this stop request response .
source share