I am new to autofac. I am using it on my new web api 2 project. The following is my autofac config code called by the Global.asax's Application_Start() method. I am not sure whether my usage of InstancePerRequest() is correct or not. More importantly, is it even need to be used at all? Or, instead I should use other options such as InstancePerLifeTimeScopre() or InstancePerDependency()? Whether I use any of these lifetime scope options or not, during debug, they produce same results.
public class IocConfig
{
//Autofac configuration
public static void Configure()
{
ContainerBuilder builder = new ContainerBuilder();
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
builder.RegisterType<DeliveryCode>().As<IDeliveryCode>()
.InstancePerRequest();
builder.RegisterType<DeliveryContext>().As<IDeliveryContext>()
.InstancePerRequest();
builder.RegisterType<DeliveryStrategy>().As<IDeliveryStrategy>()
.InstancePerRequest();
IContainer container = builder.Build();
AutofacWebApiDependencyResolver resolver = new
AutofacWebApiDependencyResolver(container);
GlobalConfiguration.Configuration.DependencyResolver = resolver;
}
}