HouseofCat.DependencyInjection.WebForms
Dependency Injection for Asp.Net WebForms (currently only Unity)
How to use
- Make sure your web project is targeting .NET Framework 4.8. You can download .NET Framework 4.8 developer pack from here. Check web.config and targetFramework in httpRuntime section should be 4.8.
<system.web>
<compilation debug="true" targetFramework="4.8"/>
<httpRuntime targetFramework="4.8"/>
</system.web>
- Install HouseofCat.DependencyInjection.WebForms.Unity nupkg in your project.
- Open Global.asax.cs and register the types in UnityContainer.
protected void Application_Start(object sender, EventArgs e)
{
var container = this.AddUnity();
container.RegisterType<ISomeInterface, SomeImplementation>();
}
Source
Original Repository no longer maintained by Microsoft is found here.