I need to provide my controller action methods access to a common class instance (lets call it UserSessionInfo) containing custom application user information.
At the moment its pulled directly from the http session by a base controller but Im trying to remove all dependencies on HTTPContext dependent objects to make the controllers cleaner and more testable.
My understanding is that there are three possible solutions,
- Inject it into the controller constructor
- ActionFilter to provide the UserSessionInfo to each action method.
- IModelBinder implementation to provide the UserSessionInfo to each action method.
I have a decent understanding of 1. Struggling to grok the differences between 2 and 3.
Any help appreciated.
Thanks,
Matt