For the sake of modularity, I have created some controllers in different assemblies. Each assembly represents a bounded context (a module, a sub-system, a division, etc.) of the overall system.
Each module's controllers are developed by someone that knows nothing about other modules, and a central orchestrator is about to cover all these modules in one single application.
So, there is this module called school, and it has a TeacherController in it. The output of it is Contoso.School.UserService.dll.
The main orchestrator is called Education and it has a reference to Contoso.School.UserService.dll.
My program.cs is:
    public static IWebHost BuildWebHost(string[] args) =>         WebHost.CreateDefaultBuilder(args).UseKestrel()             .UseStartup<Startup>()             .Build();   Yet for the routes of teacher controller, I get 404. How to use controllers in other assemblies?
In this blog you will learn how to Redirect from One Controller Action to Another. Step1: Create an ASP.net MVC project. Choose ASP.Net MVC project from template and Press Next, then name the empty project as RoutingExample and click ok. Step 2: Add two controllers.
Inside the ConfigureServices method of the Startup class you have to call the following:
services.AddMvc().AddApplicationPart(assembly).AddControllersAsServices();   Where assembly is the instance Assembly representing Contoso.School.UserService.dll.
You can load it either getting it from any included type or like this:
var assembly = Assembly.Load("Contoso.School.UserService"); 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With