I am trying to register an object in Autofac which is different for every user. I thought of using the current session, but I can not find a way to accomplish this. I am using webforms, so I can not use this. I try creating a Lifetimescope for my session but along with the multitenancy I am using, I can't get it to work. Also, the session_end is never thrown. So this is not an option.
I tried almost everything but it's either not the wanted behavior (I want that the object lives in the users session, so when I update the object I want it to be saved there too) or it does not work:
- Registering HttpSessionStateWrapper in Autofac and make my object dependent on it using InstancePerOwned
- Create a custom ContainerProvider, add a SessionLifeTime ILifetimeScope. Create a lifetimescope in Session_Start and resolve it
- Create a SessionWrapper with a Get< T > method which will return the object from the session for me and register this object in my container.
Is there a way to resolve the same object for each user's session?
Hope somebody can help!