Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a RegisterMvcControllers and RegisterMvcViewComponents overload that take assemblies or types. #665

Open
malylemire1 opened this Issue Feb 22, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@malylemire1
Copy link

malylemire1 commented Feb 22, 2019

Hi,

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.

Thanks

@malylemire1 malylemire1 changed the title Add an RegisterMvcControllers and RegisterMvcViewComponents overload that take assemblies or types. Add a RegisterMvcControllers and RegisterMvcViewComponents overload that take assemblies or types. Feb 22, 2019

@dotnetjunkie

This comment has been minimized.

Copy link
Collaborator

dotnetjunkie commented Feb 22, 2019

Those two extension methods integrate with ASP.NET Core MVC and use the supplied PartManager infrastructure to get the correct controllers and components.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.