I created a RazorViewEngine subclass to redefine where it looks for views.
I set PartialViewLocationFormats string array to contain values
"~/Views/{1}/{0}.cshtml",
"~/Views/{1}/Partial/{0}.cshtml",
"~/Views/Shared/{0}.cshtml",
The first and last are there by default. The 2nd one is the one I added, so that I could have a "Partial" subfolder in each "Views/ControllerName" folder for partial views used only by views within that controller, rather than adding them to the "Views/Shared" folder.
The issue I'm encountering is that calling @Html.Partial("_TopNavbar")
is finding and rendering the '_TopNavbar.cshtml" file that's in the "Views/Shared" folder, rather than in the one under my DashBoards's "Views/Dashboard/Partial" folder.
In other words, there are two different files named "_TopNavbar.cshtml" in two different folders, and I'm expecting it to be found in one location because it's more specific and occurs first in the array, but it's not working that way for some reason I don't understand.
The Partial call is inside "Views/Dashboard/Index.cshtml', and I'm accessing it by directly navigating to "localhost:port/Dashboard/Index", so I'm sure the controller and action are correct.