Reputation: 6265
Using Autofac in ASP.NET Core 1.0.
I want to be able to use InstancePerMatchingLifetimeScope()
on my per-request scoped registrations, so that if a dependency can't be resolved from the intended lifetime scope I will get an error, rather than a fallback to the root lifetime scope which leads to subtle runtime errors that are hard to trace.
However, I don't know what tag to use - in prior versions of ASP.NET it would have been something like "AutofacWebRequest", but that doesn't work anymore.
Is there a way to access a named scope for ASP.NET Core for matching? Or, failing that, is there some other solution to this problem?
Upvotes: 2
Views: 645
Reputation: 23924
There is no tag on the request scope in .NET Core because Autofac isn't in charge of creating the request scope anymore. There is no workaround for it. See the docs here.
Upvotes: 2