Skip to content

Registration of filters on base classes no longer work #45

@mciancia8

Description

@mciancia8

I have two filters set on two different base classes. I then have a controller (PersController) that derives from both of them.

containerBuilder.RegisterType<ExceptionFilter>()
	.As<IAutofacExceptionFilter>()
	.AsWebApiExceptionFilterFor<ApiController>()
	.InstancePerRequest();

containerBuilder.RegisterType<AuthenticationFilter>()
	.As<IAutofacAuthenticationFilter>()
	.AsWebApiAuthenticationFilterFor<AuthenticationControllerBase>()
	.InstancePerRequest();
	
public class PersController : AuthenticationControllerBase
{
}

public abstract class AuthenticationControllerBase : ApiController
{
}

With latest version (v4.3.0), if I call an API in PersController, I don't see either of these filters run. In version v4.2.1, this worked.

If I change the registration to the following, then it works:

containerBuilder.RegisterType<ExceptionFilter>()
	.As<IAutofacExceptionFilter>()
	.AsWebApiExceptionFilterFor<PersController>()
	.InstancePerRequest();

containerBuilder.RegisterType<AuthenticationFilter>()
	.As<IAutofacAuthenticationFilter>()
	.AsWebApiAuthenticationFilterFor<PersController>()
	.InstancePerRequest();

This is a huge change and I assume that this is a bug, not that this was an intended change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions