Autofac.Web
7.0.0
Prefix Reserved
dotnet add package Autofac.Web --version 7.0.0
NuGet\Install-Package Autofac.Web -Version 7.0.0
<PackageReference Include="Autofac.Web" Version="7.0.0" />
paket add Autofac.Web --version 7.0.0
#r "nuget: Autofac.Web, 7.0.0"
// Install Autofac.Web as a Cake Addin #addin nuget:?package=Autofac.Web&version=7.0.0 // Install Autofac.Web as a Cake Tool #tool nuget:?package=Autofac.Web&version=7.0.0
Autofac.Web
ASP.NET web forms integration for Autofac.
Please file issues and pull requests for this package in this repository rather than in the Autofac core repo.
Quick Start
To get Autofac integrated with web forms you need to reference the web forms integration NuGet package, add the modules to web.config
, and implement IContainerProviderAccessor
on your Global
application class.
Add the modules to web.config
:
<configuration>
<system.web>
<httpModules>
<add
name="ContainerDisposal"
type="Autofac.Integration.Web.ContainerDisposalModule, Autofac.Integration.Web"/>
<add
name="PropertyInjection"
type="Autofac.Integration.Web.Forms.PropertyInjectionModule, Autofac.Integration.Web"/>
</httpModules>
</system.web>
<system.webServer>
<modules>
<add
name="ContainerDisposal"
type="Autofac.Integration.Web.ContainerDisposalModule, Autofac.Integration.Web"
preCondition="managedHandler"/>
<add
name="PropertyInjection"
type="Autofac.Integration.Web.Forms.PropertyInjectionModule, Autofac.Integration.Web"
preCondition="managedHandler"/>
</modules>
</system.webServer>
</configuration>
Implement IContainerProviderAccessor
:
public class Global : HttpApplication, IContainerProviderAccessor
{
// Provider that holds the application container.
static IContainerProvider _containerProvider;
// Instance property that will be used by Autofac HttpModules
// to resolve and inject dependencies.
public IContainerProvider ContainerProvider
{
get { return _containerProvider; }
}
protected void Application_Start(object sender, EventArgs e)
{
// Build up your application container and register your dependencies.
var builder = new ContainerBuilder();
builder.RegisterType<SomeDependency>();
// ... continue registering dependencies...
// Once you're done registering things, set the container
// provider up with your registrations.
_containerProvider = new ContainerProvider(builder.Build());
}
}
Check out the documentation for more usage details.
Get Help
Need help with Autofac? We have a documentation site as well as API documentation. We're ready to answer your questions on Stack Overflow or check out the discussion forum.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
-
.NETFramework 4.7.2
- Autofac (>= 8.0.0)
NuGet packages (13)
Showing the top 5 NuGet packages that depend on Autofac.Web:
Package | Downloads |
---|---|
T1.Web
T1 common library |
|
YasserSystems.SharedLib
YasserSystems.SharedLib |
|
T1.Web.Mvc
T1 common library |
|
WebFormsMvp.Autofac
Provides Autofac integration for Web Forms MVP presenter resolution. |
|
WebFormsMVP.Contrib.Autofac
An Autofac-based Presenter Factory which allows custm IoC with WebForms MVP. |
GitHub repositories (3)
Showing the top 3 popular GitHub repositories that depend on Autofac.Web:
Repository | Stars |
---|---|
OrchardCMS/Orchard
Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
|
|
optimajet/WorkflowEngine.NET
WorkflowEngine.NET - component that adds workflow in your application. It can be fully integrated into your application, or be in the form of a specific service (such as a web service).
|
|
autofac/Examples
Example projects that consume and demonstrate Autofac IoC functionality and integration
|
Version | Downloads | Last updated |
---|---|---|
7.0.0 | 47,786 | 4/5/2024 |
6.1.0 | 259,708 | 8/1/2022 |
6.0.0 | 435,833 | 10/4/2020 |
5.0.0 | 627,565 | 1/31/2020 |
4.0.0 | 1,788,898 | 1/12/2016 |
3.2.0 | 440,705 | 5/9/2014 |
3.1.1 | 5,382 | 3/27/2014 |
3.1.0 | 124,174 | 7/12/2013 |
3.0.0 | 13,348 | 1/30/2013 |
3.0.0-beta2 | 1,330 | 12/23/2012 |
3.0.0-beta | 2,058 | 11/1/2012 |
2.6.3.862 | 138,939 | 6/20/2012 |
2.6.2.859 | 2,456 | 6/7/2012 |
2.6.1.841 | 9,630 | 3/5/2012 |
2.5.2.830 | 6,119 | 8/12/2011 |
2.5.1.827 | 2,839 | 7/10/2011 |
2.4.5.724 | 9,786 | 3/12/2011 |
2.4.4.705 | 2,844 | 2/6/2011 |
2.4.3.700 | 3,001 | 1/30/2011 |
2.4.2.696 | 4,748 | 1/24/2011 |
2.3.2.632 | 4,333 | 1/7/2011 |
2.2.4.900 | 7,310 | 1/7/2011 |
Release notes are at https://github.com/autofac/Autofac.Web/releases