Skip to content

ASP Net Core - Controllers as Services with Attribute Filtering #13

@oh-yeah

Description

@oh-yeah

Describe the Bug

How can I add attribute filtering to controllers in in a Net 8 Mvc Project? Based on the documentation, controllers need to be configured as service in order to for them to be to be resolved by Autofac. I'm unable to find any hooks into this registration pipeline for attribute filtering as this registration happens with the service collection.

Steps to Reproduce

Create a Net8 Mvc Project and register the controllers as services using the following configuration.

public void ConfigureServices(IServiceCollection services)
{
      services.AddControllersWithViews(o => { /* global filters and auth could be added here */})
              .AddControllersAsServices();
}

Expected Behavior

I should be able to apply attribute filtering, using WithAttributeFiltering(), to these controllers.

Exception with Stack Trace

N/A

Dependency Versions

Autofac: 7.1.0
Autofac.Extensions.DependencyInjection: 8.0.0.0
Autofac.Extras.AttributeMetadata: 6.0.0.0

Additional Info

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