StructureMap3 session-scoped singleton - no session variable?

71 Views Asked by At

I'm fairly new to StructureMap. I'm trying to create a session-scoped singleton class (using MVC4 with Sitecore). After some googling i came up with this:

x.For<IMyClass>().LifecycleIs(new HttpSessionLifecycle()).Use<MyClass>();

Issue is that MyClass is instantiated with another class instance

x.For<ISomeAPIClient>()
                .HttpContextScoped()
                .Use((context) => GetApiClient(context));

and this instance, when called from MyClass, does not appear to have access to HttpContext Session - it is null. I think i've tried every built-in lifecycle and have ended up either with the same result or the class not behaving as a session-scoped singleton.
What am i doing wrong?

0

There are 0 best solutions below