-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Thank you for creating this repo and pushing Microsoft to add more flexibility in choice of containers.
Using the sample Ninject, project, I set everything up but I'm getting an error when I try to resolve/active a filter of type IAuthorizationFilter which depends on a types in my container.
Is there a way to replace the activator for filters? I tried to replace the IFilterProvider via:
public static void AddCustomFilterProvider(this IServiceCollection services,
Func<Type, object> provider)
{
if (services == null) throw new ArgumentNullException(nameof(services));
if (provider == null) throw new ArgumentNullException(nameof(provider));
services.AddSingleton<IFilterProvider>(new DelegatingFilterProvider(provider));
}But I wasn't able to get a breakpoint in DelegatingFilterProvider to hit. DelegatingFilterProvider just inherits from DefaultFilterProvider at the moment.
Here's the relevant part of the exception:
System.InvalidOperationException: Unable to resolve service for type 'Omar.IMyService' while attempting to activate 'Omar.MyFilter'.
at Microsoft.Extensions.Internal.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)
at lambda_method(Closure , IServiceProvider , Object[] )
at Microsoft.AspNetCore.Mvc.TypeFilterAttribute.CreateInstance(IServiceProvider serviceProvider)
at Microsoft.AspNetCore.Mvc.Internal.DefaultFilterProvider.ProvideFilter(FilterProviderContext context, FilterItem filterItem)
at Microsoft.AspNetCore.Mvc.Internal.DefaultFilterProvider.OnProvidersExecuting(FilterProviderContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvokerCache.GetFilters(ActionContext actionContext, List`1 filterItems)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvokerCache.GetState(ControllerContext controllerContext)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker..ctor(ControllerActionInvokerCache cache, IControllerFactory controllerFactory, IControllerArgumentBinder controllerArgumentBinder, ILogger logger, DiagnosticSource diagnosticSource, ActionContext actionContext, IReadOnlyList`1 valueProviderFactories, Int32 maxModelValidationErrors)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvokerProvider.OnProvidersExecuting(ActionInvokerProviderContext context)
at Microsoft.AspNetCore.Mvc.Internal.ActionInvokerFactory.CreateInvoker(ActionContext actionContext)
at Microsoft.AspNetCore.Mvc.Internal.MvcRouteHandler.<>c__DisplayClass8_0.<RouteAsync>b__0(HttpContext c)
at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
Any thoughts on how to do that?
Metadata
Metadata
Assignees
Labels
No labels