In looking at http://code.google.com/p/autofac/wiki/AspNetIntegration, I am confused as to what the lifetime of objects registered with ContainerScoped() is.
The page states:
The ContainerDisposalModule lets Autofac dispose of any components created during request processing as soon as the request completes.
Which seems to me to indicate that ContainerScoped() registrations would return the same instance for every resolve during a single HttpRequest – and that no given object instance would be shared across HttpRequests.
However, if that were the case, I don’t see the purpose of the HttpRequestScoped() method, which makes me believe that I am missing something.
What is the object lifetime of ContainerScoped() registrations when using Autofac.Integration.Web.ContainerDisposalModule in ASP.NET?
Are you using an old version of Autofac? Off the top of my head the method “ContainerScoped()” is called “InstancePerLifetimeScope” in later versions and I think (not sure though) that the “HttpRequestScoped” function is deprecated. Anyhow, the two methods would be equivalent since a lifetime scope (child container) is created per request.