Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Add a RegisterMvcControllers and RegisterMvcViewComponents overload that take assemblies or types. #665
Can you add a RegisterMvcControllers and RegisterMvcViewComponents overload that take assemblies or types.
This will enable adding registration in ConfigureServices. For assemblies it should scan for Microsoft.AspNetCore.Mvc.ControllerBase or ViewComponent in exported types.
Those two extension methods integrate with ASP.NET Core MVC and use the supplied
Adding overloads would not be useful, because in that case ASP.NET Core doesn't know about rhe existence of these classes, while it should be.
Instead, the advised way of loading controllers and components using alternative assemblies is, therefore, by using the method given by ASP.NET Core:
services.AddMvc() .AddApplicationPart(typeof(<class in external assembly>).Assembly);
When an application part is added, the extension methods will automatically pick up the controllers and components located in that part/assembly.