Can you inject a session reference into your class via structure map
Asked
Active
Viewed 667 times
-2
-
2What's the programming language? What's the context, why are you trying to do this? – Alex Weinstein Dec 02 '09 at 09:05
1 Answers
2
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
- 8,527
- 2
- 31
- 40