ASP.NET MVC 3, RavenDB, & Autofac Issue Plus 2 Other Autofac Questions

前端 未结 2 1290
-上瘾入骨i
-上瘾入骨i 2021-01-05 05:08

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

2条回答
  •  北海茫月
    2021-01-05 05:43

    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.

提交回复
热议问题