Autofac.WebApi2 7.0.0

Prefix Reserved
dotnet add package Autofac.WebApi2 --version 7.0.0
                    
NuGet\Install-Package Autofac.WebApi2 -Version 7.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Autofac.WebApi2" Version="7.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Autofac.WebApi2" Version="7.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Autofac.WebApi2" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Autofac.WebApi2 --version 7.0.0
                    
#r "nuget: Autofac.WebApi2, 7.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Autofac.WebApi2@7.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Autofac.WebApi2&version=7.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Autofac.WebApi2&version=7.0.0
                    
Install as a Cake Tool

Autofac.WebApi

ASP.NET Web API integration for Autofac.

Build status codecov NuGet

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 API you need to reference the Web API integration NuGet package, register your controllers, and set the dependency resolver. You can optionally enable other features as well.

protected void Application_Start()
{
  var builder = new ContainerBuilder();

  // Get your HttpConfiguration.
  var config = GlobalConfiguration.Configuration;

  // Register your Web API controllers.
  builder.RegisterApiControllers(Assembly.GetExecutingAssembly());

  // OPTIONAL: Register the Autofac filter provider.
  builder.RegisterWebApiFilterProvider(config);

  // OPTIONAL: Register the Autofac model binder provider.
  builder.RegisterWebApiModelBinderProvider();

  // Set the dependency resolver to be Autofac.
  var container = builder.Build();
  config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
}

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 Compatible and additional computed target framework versions.
.NET Framework net481 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (87)

Showing the top 5 NuGet packages that depend on Autofac.WebApi2:

Package Downloads
Autofac.WebApi2.Owin

ASP.NET Web API OWIN integration for Autofac.

iRely.Common

iRely.Common

BumperLane.Tenant.Api.Framework

Framework for BumperLane API sites

Purplelight.Framework.Autofac.Integration.WebApi

Productivity enhancements to Autofac WebApi Integration

TouchConvert.Tenant.Api.V1.Dtos

Data transfer objects for TouchConvert version one APIs.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Autofac.WebApi2:

Repository Stars
smartstore/SmartStoreNET
Open Source ASP.NET MVC Enterprise eCommerce Shopping Cart Solution
Version Downloads Last Updated
7.0.0 107,985 7/20/2026
6.2.0 676,415 10/25/2025
6.1.1 4,776,889 8/2/2022
6.1.0 1,219,744 11/18/2021
6.0.1 1,948,582 12/1/2020
6.0.0 1,794,456 9/30/2020
5.0.0 4,277,604 1/30/2020
4.3.1 3,146,224 9/5/2019
4.3.0 333,277 8/15/2019
4.2.1 2,264,155 3/26/2019
4.2.0 4,086,063 6/21/2018
4.1.0 4,484,896 8/2/2017
4.0.1 4,901,277 10/24/2016
4.0.0 3,015,831 8/17/2016
4.0.0-rc3-225 5,029 8/3/2016
4.0.0-beta7-215 38,546 9/23/2015
3.4.0 5,566,159 8/17/2014
3.3.3 227,241 7/2/2014
3.3.0 93,300 5/9/2014
3.2.1 41,939 3/27/2014
Loading failed