Skip to content

Instantly share code, notes, and snippets.

@NatMarchand

NatMarchand/Global.asax.cs Secret

Created May 4, 2018
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