I'm using the Unity container for dependency injection in an ASP.NET MVC 4 application.
For a particular controller (say ProductController), I have an dependency injection scenario as follows:
- The ProductController constructor takes a IProductsRepository instance.
- The IProductsRepository implementation has a constructor that accepts a IProductsService instance.
- The IProductsService implementation has a constructor that accepts an authentication token string, which is retrieved from a cookie in the web request.
What's the correct way to do automatic dependency injection in this scenario, considering that the authentication token cookie can only be retrieved after the controller instance has been created?