Closed timomta closed 1 year ago
I cloned the repo and debugged. The problem was that a class placed in session state was not marked serializable. As a result, serialization failed in this session provider. However, this provider swallows the exception (which actually states the problem and what it could not serialize) and returns a null:
RedisConnectionWrapper.cs
private byte[] SerializeSessionStateItemCollection(ISessionStateItemCollection sessionStateItemCollection)
{
try
{
MemoryStream ms = new MemoryStream();
BinaryWriter writer = new BinaryWriter(ms);
((SessionStateItemCollection)sessionStateItemCollection).Serialize(writer);
writer.Close();
return ms.ToArray();
}
catch <-- Exception swallowed
{
return null;
}
}
It would save a lot of debugging time if the exception was logged or communicated in some way. It isn't always clear that a particular class is not serializable, especially when embedded within a parent class.
Merged a PR removing trycatch from both serialization and deserialization methods
Would be nice to get the class name where the missing serializable attribute was found within the exception.
I'm getting a null reference exception from the Redis ASP.Net session state provider via the StackExchangeClient. It is not coming directly from the application code, so I'm not sure exactly what is going on. Is it possible that the value of a given session state key/value pair was set to null and that caused an exception in the provider? For example, if Session("myKey") = null (a particular value was set to null) somehow happened, would that break the session state provider?
The application code (old code) I am working with works fine with the InProc provider.
The exception is a null reference:
Since it is thrown from session state client worker threads, it is difficult to determine the exact place in the application causing the issue.