Use "web" instead. When using managed_web you need to use Bind() etc. on ManagedWebSessionContext. With all the others you use methods on CurrentSessionContext. This is actually documented in the reference, but the text has to be read carefully - it's easy to miss this I think.
According to issue NH-990, which was about adding WebSessionContext (and others), the ManagedWebSessionContext is deprecated. Note to committers: Is it true that ManagedWebSessionContext is regarded as deprecated? If so, I think it would be nice if the reference, section 2.3. Contextual Sessions mentioned this. Currently it provides no guidance between "web" and "managed_web", and even lists the second one at the top. Also, the class ManagedWebSessionContext should be marked with [Obsolete("Use WebSessionContext and CurrentSessionContext instead.")]. Or perhaps the class should even be removed in trunk for NH 3.0? /Oskar 2009/10/21 kork <korkl...@gmail.com>: > > hi all, i'm using nhibernate 2.0.1 (but the involved classes are the > same in the last version). > > i try to set ManagedWebSessionContext by nhibernate config > (<property name="current_session_context_class">managed_web</ > property>) > > but the problem is that when same static methods of > > NHibernate.Context.CurrentSessionContext > > is involved (as HasBind, etc) there's a calls to the internal method > GetCurrentSessionContext. > > My problem is that internally this method cast the property > factoryImpl.CurrentSessionContext to the type CurrentSessionContext > but ManagedWebSessionContext doesn't inherit from it (it directly > implements the interface ICurrentSessionContext) so i have an cannot > cast exception. > > i think that there's samething simple and obvious that i cannot see, > can help me samebody to understand where i wrong? > > thanks