-
-
Save NatMarchand/fa8777ad6b83a1b3a60deb204f425d85 to your computer and use it in GitHub Desktop.
webformdependencyinjection_autofac3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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