I follow the ninject filter attribute setting on this page .
For them they have:
.WithConstructorArgumentFromControllerAttribute<LogAttribute>( "logLevel", attribute => attribute.LogLevel);
The second parameter expects Func<LogAttribute, object> callback . Their actual parameter list is configured as follows:
Log(LogLevel = Level.Debug)
But my filter attribute is configured as follows:
public class AuthAttribute : FilterAttribute { } public class AuthFilter : IAuthorizationFilter { private readonly IUserService userService; private string[] roles;
Somehow this is wrong. Because I want my filter to look like this:
[Auth("Admin", "Contrib")]
My bindings:
kernel.BindFilter<AuthFilter>(FilterScope.Controller, 0) .WhenControllerHas<AuthAttribute>() .WithConstructorArgumentFromControllerAttribute<AuthAttribute>("roles", )
asp.net-mvc asp.net-mvc-3 ninject
Shawn Mclean Jun 01 2018-11-11T00: 00Z
source share