In Razor, I have a few that’s located in "~/areas/shared/views/shared/_partialName.cshtml". If I do simply @{ Html.RenderPartial("_partialName", myModel"); } in my view, it cannot find it. I instead have to fully qualify the path to that partial.
Can I tell my project to include the folder "~/areas/shared/views/shared/" in the list of folders it crawls when trying to find partials? This way I can keep the snippet of code in my view to render that partial nice and short. Thanks!
The RazorViewEngine class contains properties which have patterns for where it should look for various view files – areas, partials, everything. You can override it pretty easily and tell your application in Globals.asax to use your implementation instead:
Note that since it sounds like you’re working with Areas, there’s another property that you can override called
AreaViewLocationFormatswhich you can update in the same manner and insert “{2}” as the name of the area.