-2

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

ps2goat
  • 8,067
  • 1
  • 35
  • 68
monkeylee
  • 965
  • 3
  • 15
  • 32

1 Answers1

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