Autofac.Mvc5.Owin
6.1.0
Prefix Reserved
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" />
paket add Autofac.Mvc5.Owin --version 6.1.0
#r "nuget: Autofac.Mvc5.Owin, 6.1.0"
// Install Autofac.Mvc5.Owin as a Cake Addin #addin nuget:?package=Autofac.Mvc5.Owin&version=6.1.0 // Install Autofac.Mvc5.Owin as a Cake Tool #tool nuget:?package=Autofac.Mvc5.Owin&version=6.1.0
Autofac.Mvc.Owin
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.
Quick Start
If you are using MVC as part of an OWIN application, you need to:
- Do all the stuff for standard MVC integration - register controllers, set the dependency resolver, etc.
- Set up your app with the base Autofac OWIN integration.
- Add a reference to the
Autofac.Mvc5.Owin
NuGet package. - In your application startup class, register the Autofac MVC middleware after registering the base Autofac middleware.
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.
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.Owin (>= 7.0.0)
NuGet packages (2)
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 |
GitHub repositories (1)
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 | 184,818 | 8/23/2022 |
6.0.0 | 557,336 | 10/5/2020 |
5.0.0 | 329,101 | 1/31/2020 |
4.0.1 | 1,416,213 | 2/8/2017 |
4.0.0 | 205,023 | 8/10/2016 |
4.0.0-rc3-217 | 2,141 | 7/25/2016 |
3.1.0 | 332,788 | 8/21/2014 |
3.0.1 | 4,361 | 6/20/2014 |
3.0.0 | 2,137 | 6/20/2014 |
3.0.0-alpha3 | 1,314 | 3/27/2014 |
3.0.0-alpha2 | 1,191 | 3/26/2014 |
3.0.0-alpha | 1,145 | 2/17/2014 |
Release notes are at https://github.com/autofac/Autofac.Mvc.Owin/releases