NOTE: There are 3 questions in here and I did not make separate questions since they are all somewhat related to the same code.
I have the following
I'm guessing you want something like:
builder.Register(c => c.Resolve().OpenSession()).InstancePerLifetimeScope();
"The default ASP.NET and WCF integrations are set up so that InstancePerLifetimeScope() will attach a component to the current web request or service method call." - Autofac: InstanceScope
Basically, in a web app, InstancePerLifetimeScope
handles the one per HTTP context aspect, and also disposes any types that implement IDisposable
.