![]() |
VOOZH | about |
dotnet add package Autofac.Mvc5.Owin --version 6.1.0
NuGet\Install-Package Autofac.Mvc5.Owin -Version 6.1.0
<PackageReference Include="Autofac.Mvc5.Owin" Version="6.1.0" />
<PackageVersion Include="Autofac.Mvc5.Owin" Version="6.1.0" />Directory.Packages.props
<PackageReference Include="Autofac.Mvc5.Owin" />Project file
paket add Autofac.Mvc5.Owin --version 6.1.0
#r "nuget: Autofac.Mvc5.Owin, 6.1.0"
#:package Autofac.Mvc5.Owin@6.1.0
#addin nuget:?package=Autofac.Mvc5.Owin&version=6.1.0Install as a Cake Addin
#tool nuget:?package=Autofac.Mvc5.Owin&version=6.1.0Install as a Cake Tool
OWIN support for the ASP.NET MVC integration for Autofac.
Please file issues and pull requests for this package in this repository rather than in the Autofac core repo.
If you're working with ASP.NET Core, you want Autofac.Extensions.DependencyInjection, not this package.
If you are using MVC as part of an OWIN application, you need to:
Autofac.Mvc5.Owin NuGet package.public class Startup
{
public void Configuration(IAppBuilder app)
{
var builder = new ContainerBuilder();
// STANDARD MVC SETUP:
// Register your MVC controllers.
builder.RegisterControllers(typeof(MvcApplication).Assembly);
// Run other optional steps, like registering model binders,
// web abstractions, etc., then set the dependency resolver
// to be Autofac.
var container = builder.Build();
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
// OWIN MVC SETUP:
// Register the Autofac middleware FIRST, then the Autofac MVC middleware.
app.UseAutofacMiddleware(container);
app.UseAutofacMvc();
}
}
Minor gotcha: MVC doesn't run 100% in the OWIN pipeline. It still needs HttpContext.Current and some other non-OWIN things. At application startup, when MVC registers routes, it instantiates an IControllerFactory that ends up creating two request lifetime scopes. It only happens during app startup at route registration time, not once requests start getting handled, but it's something to be aware of. This is an artifact of the two pipelines being mangled together.
Check out the Autofac ASP.NET MVC integration documentation for more information.
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 net472 is compatible. net48 net48 was computed. net481 net481 was computed. |
Showing the top 2 NuGet packages that depend on Autofac.Mvc5.Owin:
| Package | Downloads |
|---|---|
|
bscheiman.Common.Aspnet
Useful extensions/tools/utils I keep using all over the place. Hit me up (@bscheiman) if you need help. |
|
|
Inovout.Web.Mvc-KuaJing
support OWIN |
Showing the top 1 popular GitHub repositories that depend on Autofac.Mvc5.Owin:
| Repository | Stars |
|---|---|
|
NuGet/NuGetGallery
NuGet Gallery is a package repository that powers https://www.nuget.org. Use this repo for reporting NuGet.org issues.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 6.1.0 | 456,218 | 8/23/2022 |
| 6.0.0 | 685,629 | 10/5/2020 |
| 5.0.0 | 417,941 | 1/31/2020 |
| 4.0.1 | 1,586,039 | 2/8/2017 |
| 4.0.0 | 235,551 | 8/10/2016 |
| 4.0.0-rc3-217 | 2,647 | 7/25/2016 |
| 3.1.0 | 349,666 | 8/21/2014 |
| 3.0.1 | 5,310 | 6/20/2014 |
| 3.0.0 | 3,219 | 6/20/2014 |
| 3.0.0-alpha3 | 1,801 | 3/27/2014 |
| 3.0.0-alpha2 | 1,673 | 3/26/2014 |
| 3.0.0-alpha | 1,631 | 2/17/2014 |
Release notes are at https://github.com/autofac/Autofac.Mvc.Owin/releases