Skip to content

Instantly share code, notes, and snippets.

@NatMarchand
Created May 4, 2018 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NatMarchand/fa8777ad6b83a1b3a60deb204f425d85 to your computer and use it in GitHub Desktop.
Save NatMarchand/fa8777ad6b83a1b3a60deb204f425d85 to your computer and use it in GitHub Desktop.
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