Storing objects in the .net session in sharepoint

By mkozelsky

In our webparts, we’re storing objects in the ASP.NET Session. Whenever we would set the value in the session, SharePoint would just stop working. It would give an Error page with no reason for the failure.

If i put a string or int in the session, it would work fine, but not our custom objects we’re creating. I played with serialization for a while, but our object hierarchy is too complicated to serialize every class that’s an attribute of another.

To get it to work, i had to change the webconfig:

<sessionState mode="SqlServer" timeout="10" allowCustomSqlDatabase="true" partitionResolverType="Microsoft.Office.Server.Administration.SqlSessionStateResolver, Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />

to

<sessionState mode="InProc" timeout="10" />

Apparently, you can’t use SqlServer mode for the session state, which is the default for sharepoint.

Tags:

Leave a Reply