Wednesday, December 9, 2009

Session state is corrupted

If you got some error like that – the problem is in your TV, not in IIS, not in Sharepoint :-))

Exception message: The session state information is invalid and might be corrupted.

Stack trace:    at System.Web.SessionState.SessionStateItemCollection.Deserialize(BinaryReader reader)
   at System.Web.SessionState.SessionStateUtility.Deserialize(HttpContext context, Stream stream)
   at System.Web.SessionState.SqlSessionStateStore.DoGet(HttpContext context, String id, Boolean getExclusive, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actionFlags)
   at System.Web.SessionState.SqlSessionStateStore.GetItemExclusive(HttpContext context, String id, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actionFlags)
   at System.Web.SessionState.SessionStateModule.GetSessionStateItem()
   at System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData)
   at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

image

This occurs when there is a null value used for a Session Key and later a string based session key is used.

- Code adds a Null session key - this works and there are no errors.

- At a later request, code adds a string session key.

You are doing one of the following:

Object var = SomeFunction();

Session[var] = AnotherObject;

Or

Session[SomeFunction()] = AnotherObject;

You need to the return value and ensure it is not null!

No comments:

Post a Comment