Skip to content
develop
Go to file
Code

Files

Permalink
Failed to load latest commit information.

README.md

Autofac.AspNetCore.Multitenant

ASP.NET Core support for multitenant DI via Autofac.Multitenant.

Build status codecov

Please file issues and pull requests for this package in this repository rather than in the Autofac core repo.

Why Use This?

ASP.NET Core default RequestServicesContainerMiddleware is where the per-request lifetime scope usually gets generated. However, its constructor is where it wants the IServiceScopeFactory that will be used later during the request to create the request lifetime scope.

Unfortunately, that means the IServiceScopeFactory is created/resolved at the point when the request comes in, long before an HttpContext is set in any IHttpContextAccessor. The result is the scope factory ends up coming from the default tenant scope, before a tenant can be identified, and per-request services will later all come from the default tenant. Multitenancy fails.

This package provides a different request services middleware that ensures the IHttpContextAccessor.HttpContext is set and defers creation of the request lifetime scope until as late as possible so anything needed for tenant identification can be established.

Reference

About

Enables multitenant dependency injection support for ASP.NET Core.

Resources

License

Packages

No packages published
You can’t perform that action at this time.