I previously asked a question here about autofac not disposing my objects when the HTTP request ends. I now think I have a bigger problem, becuasse there is evidence that it is serving up the SAME object request-to-request. Again, I am using thier instructions here. My test is a bit more complex because I'm using the delegate syntax to create an object but I think I'm flagging it for request-lifetime. Global.asax.cs:
protected void Application_Start(object sender, EventArgs e)
{
...
var builder = new Autofac.Builder.ContainerBuilder();
builder.Register<IDBConnectionSelector>(
(c) => new CachingDBConnections(ConstructorArgs...))
.HttpRequestScoped();
var container = builder.Build();
_containerProvider = new ContainerProvider(container);
}
public IContainerProvider ContainerProvider
{
get { return _containerProvider; }
}
static IContainerProvider _containerProvider;
My intention here is to register IDBConnectionSelector to get the concrete type CachingDBConnections created with a custom constructor but with HTTP request scope.
Some methods of the CachingDBConnections object is failing on subsequent requests in a way that leads me to believe I'm getting the same one I got last time and not a NEW one for every request.
Does that make sense? What am I doing wrong?