Skip to content

Instantly share code, notes, and snippets.

@NatMarchand
Created May 4, 2018 12:06
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
webformdependencyinjection_autofac3
using System;
using System.Web;
namespace Autofac.Integration.Web.Sample
{
public class Global : HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
var builder = new ContainerBuilder();
builder.RegisterType<Dependency>().As<IDependency>().InstancePerRequest();
builder.RegisterSource(new WebFormRegistrationSource());
var container = builder.Build();
var provider = new AutofacServiceProvider(container);
HttpRuntime.WebObjectActivator = provider;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment