Skip to content

Question: Controller discovery across multiple assemblies using new routing system #13850

Closed
@kimbell

Description

@kimbell

I have a class library containing a Controller currently working on 2.0. I'm in the process of migrating things over to 3.0 using preview 9.

My class library has a test project that sets up things using WebApplicationFactory. In 2.0 the controller in my class library was automatically discovered. With the new routing system, it cannot find the path handled by the controller.

This is how I've set things up in the test project. Am I missing something?

protected override void ConfigureWebHost(IWebHostBuilder webhostBuilder)
        {
            webhostBuilder
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseDefaultServiceProvider(p => p.ValidateScopes = true)
                .ConfigureServices((context, services) =>
                    {
                        services.AddControllers();
                    })
                .Configure(appBuilder =>
                {
                    appBuilder.UseRouting();
                    appBuilder.UseEndpoints(config =>
                    {
                        config.MapControllers();
                    });
                });
        }
´´´

Metadata

Metadata

Assignees

Labels

area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesinvestigate

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions