views:

79

answers:

1

Can you inject a session reference into your class via structure map

+1  A: 

Yes.

If you are referring to the HTTP Session for the current user, try adding this to your container registration code:

For<HttpSessionStateBase>().TheDefault.Is.ConstructedBy(() => new HttpSessionStateWrapper(HttpContext.Current.Session));

Now any class retrieved via StructureMap that takes an HttpSessionStateBase as one of its constructor parameters should get the current session.

Joshua Flanagan

related questions