I have the following code in an Autofac Module that is used in my Application_Start method:
builder.Register(c => new Configuration().Configure().BuildSessionFactory())
.SingletonScoped();
builder.Register(c => c.Resolve<ISessionFactory>().OpenSession())
.HttpRequestScoped();
builder.Register<NHibernateSomethingRepository>().As<ISomethingRepository>();
The constructor for the repository takes an ISession as argument. But I end up with one session for the whole application, even though I explicitly asked for it to be HttpRequestScoped.
I have configured the ContainerDisposal HTTP module.
According to the documentation you have to create a nested container, but I'm letting Autofac autowire the dependencies.
What should I do?
Thanks!