Trying to inject property to my custom AuthorizeAttribute but this attribute always comes null. Is this registration wrong?
public class AuthenticateAttribute : AuthorizeAttribute
{
public IAuthenticationService authenticationService { get; set; }
public UserTypes UserType;
public AuthenticateAttribute()
{
}
}
**Calling From Global Asax**
public static void InitializeDependencies()
{
var builder = new ContainerBuilder();
var config = GlobalConfiguration.Configuration;
builder.RegisterAssemblyTypes(Assembly.Load("BusinessServices"))
.Where(t => t.Name.EndsWith("Service"))
.AsImplementedInterfaces()
.InstancePerLifetimeScope();
builder.RegisterAssemblyTypes(Assembly.Load("BusinessEntities"))
.Where(t => t.Name.EndsWith("Helper"))
.AsImplementedInterfaces()
.InstancePerLifetimeScope();
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
builder.RegisterWebApiFilterProvider(config);
builder.Register(x => new ApiExceptionHandler(x.Resolve<ILogService>())).AsWebApiExceptionFilterFor<ApiController>().InstancePerLifetimeScope();
builder.RegisterType<AuthenticateAttribute>().PropertiesAutowired().InstancePerLifetimeScope();
var container = builder.Build();
config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
}
http://stackoverflow.com/questions/41842119/web-api-2-autofac-authorizeattribute-property-injection-doesnt-work