Owin Context use one instance per request

app.CreatePerOwinContext(DataContext.Create);

      

I have the line above to create a data context, this code came with a project when I kick in a new MVC 5 project. At the same time, I am using autofac to inject one instance per request in my dependency logger.

builder.RegisterType<DataContext>().As<IDbContext>().InstancePerRequest();

What is the best way to use the owin container and DI?

I have a DataContext class that has a static method called Create

as above and this break when I try to inject the logger into the database class for example.

I am also interested in a sample project, if any, demonstrating DI and owin in the same project.

+3


source to share


1 answer


If you don't fetch the instance created by the OWIN middleware, and instead insert your context into your controllers, you can safely delete it. Remember to update your forest controllers accordingly.



+1


source







All Articles