Print Page | Close Window

ASP.NET session state

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2818
Printed Date: 26-Jan-2026 at 4:04pm


Topic: ASP.NET session state
Posted By: scottarlp
Subject: ASP.NET session state
Date Posted: 11-Jul-2011 at 10:06am
I needed to switch over to SQL session state for asp.net and I've run into a problem where IB entities aren't serialized (at least the session manager doesn't think they are). So I do a normal entity manager call and get an entity set back. Trying to put this in Session throws an error "Unable to serialize the session state...".
Everything I've found so far says that you need the serialize attribute on the class and I see where there's a datacontract attribute, but I have run into problems before where I had to have both. Is there an easy way to handle this? I would hate to either call the database every time to get this data or create a dummy class to transition the entity to.
 
Thanks.



Replies:
Posted By: robertg
Date Posted: 11-Jul-2011 at 11:33am
Scott,
 
Rather than trying to serialize the EntityManager, what you actually want to use is the EntityCacheState. You can take that cache state, store it in your session, and then restore it into your EntityManager on your next page load, thus providing the data persistence you're looking for.
 
Here's the relevant page on the DRC for using the CacheState.
 
http://drc.ideablade.com/xwiki/bin/view/Documentation/start-entity-cache#HExportcacheasanEntityCacheState - http://drc.ideablade.com/xwiki/bin/view/Documentation/start-entity-cache#HExportcacheasanEntityCacheState
 
Yours,
Robert



Print Page | Close Window