I have a C# Solution containing two projects : Client (parent) and RestAPI (child). From the client project, I'm loading a ASP.NET server. Currently, my RestAPI is successfully loading controllers from the client project using services.AddControllersWithViews().AddApplicationPart(assembly);. Currently, only the controllers can be loaded, though, I want to use some views too.
To summarize, what I'm trying to do is to use views that are located into my Client project by the RestAPI project.
What I've tried to do :
services.AddControllersWithViews().AddApplicationPart(assembly);=> It loads only the controllersservices.AddMvc().AddApplicationPart(assembly);=> Same results- Returning a static path to the view file (i.e. :
return View("C:\Simon\...");)
Project structure :
In the controller DevicesController.cs, I have to following function:
[Route("show")]
[HttpGet]
public ViewResult Show()
{
return View("Home");
}
I want to return the view in the Views folder located under Client project. However, It only returns the one located under RestAPI. If I remove the one in RestAPI, the application crashes with the following error logs :
System.InvalidOperationException: The view 'Home' was not found. The following locations were searched: /Views/Devices/Home.cshtml /Views/Shared/Home.cshtml
