Have you checked out this great DI blog with Unity and ASP.NET MVC?
It should turn out on the right track.
The answer is yes , you can - and the article shows how.
In short, you create an HttpContextLifetimeManager to handle the "scope" of your objects. The container "caches" the instance in an HTTP context.
This is necessary because the default lifetime managers provided by Unity do not cover the scope of the HTTP context from the shelf.
Of course, another DI container (such as StructureMap - which I use) does.
Here is another (more modern) article about the same, with the example of "Nerdinner".
RPM1984 10 Oct '10 at 8:05 2010-10-10 08:05
source share