When trying to create a generic .NET Core MVC controller that returns views, the views aren't found(Error message: "Cannot resolve View Details"). This is happening because, the generic controller isn't tied to a specific view. The view should be picked based on what the T is. I've seen some examples of this in ASP.NET, but I'm unable recreate those in .NET Core.
Is there a good way to solve this problem in .NET Core?
Generic controller example:
public class ControllerBase<T> : Controller where T : class
{
private IManager<T> _manager;
public ControllerBase( IManager<T> manager)
{
_manager = manager;
}
public async Task<IActionResult> Details(int? id)
{
if (id == null)
{
return NotFound();
}
var result = await _manager.Get(id);
return View(result);
}
}