asp.net core mvc: split hosting and business-logic/ui into separate projects

In addition to Kirk Larkin's comment to look at Application Parts in ASP.NET Core, you might also want to check out Razor Class Libraries.

I have not tried it myself yet, but it looks it might provide a solution for your issue.


The problem when you move your controller folder, it can not detect your controllers anymore in your Startup.cs.

There should be a line in there saying:

     app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });

According to this link, what you should do is add a namespace to it like so:

   app.UseMvc(routes =>
      routes.MapRoute(  
         name: "Default",
         url: "{controller}/{action}/{id}",
         defaults: new { controller = "Foo", action = "Index", id =      UrlParameter.Optional },
         // This will prioritize routes within your main application
         namespaces: new[] { "ProjectA.Controllers"}
      );
    });

Hope this will be useful for you.