asp.net mvc 2 - Multiple serializations on state server corrupt property value -
i have abnormal serialization/de-serialization behavior in asp.net mvc application.
setup , architecture follows:
.net 3.5, mvc 2, unity 2.0 dependency injection, iis 7. state stored in aspnet state process. application apart models, views , controllers contains number of application specific services , model mappers (for interfacing existing code). 2 of services have per session based lifetime, implemented custom persessionlifetimemanager
(as unity not have 1 out of box). lifetime manager uses httpcontext.current.session
store objects. there fair bit of dependencies between controllers, mappers, services , between services well.
problem:
one of session lifetime services contains private boolean field changes value under internal logic conditions, value changes outside of code. after investigation found problem relates object being serialized/de-serialized twice every time , values of field different during serializations.
investigation done far:
i have break points/logging on object constructor , wrapped field property , put breakpoint/logging on setter. object constructed once , there no calls change property value except should called. have made object implement iserializable
, put logging of system.threading.thread.currentthread.managedthreadid
, object hash (constructed fields of object). can see if value of property/field changes object gets serialized twice once new value , after original value. next time object used de-serializes in lifo order, original (unchanged) value object pulled out first , changed one. tried log full stack trace these serialization calls, seem .net internal calls.
questions:
why there multiple serializations different values? how avoid this?
current work around:
i used session instead of private field/property , works fine, use of session on heavily loaded websites not best thing , hoping other solution.
thank you.
are sure value becoming corrupted or loosing value due session being purged. have other values in session disappear @ same time? bit confused "state stored in aspnet state process. " statement. session management set inproc or using stateserver? if inproc, experience loss of session values (especially in shared hosting environments), , should switch asp state server service or mssql state server solution.
Comments
Post a Comment