How do I use AutofacWebTypesModule to Resolve HttpServerUtilityBase
- by Scott Weinstein
I have the following registrations
builder.RegisterModule(new AutofacWebTypesModule());
builder.Register<MyType>(ctx =>
{
var server = ctx.Resolve<HttpServerUtilityBase>();
...
});
When I try to resolve MyType via a constructor on an Controller, I get the following exception. What am I doing wrong?
Autofac.Core.DependencyResolutionException
was unhandled by user code
Message=No scope matching the
expression
'value(Autofac.Builder.RegistrationBuilder`3+<c__DisplayClass0[System.Web.HttpServerUtilityBase,Autofac.Builder.SimpleActivatorData,Autofac.Builder.SingleRegistrationStyle]).lifetimeScopeTag.Equals(scope.Tag)'
is visible from the scope in which the
instance was requested.