KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In Razor, when loading a partial view, it is possible to just specify the partial view name, and the Razor view engine will search the RazorViewEngine.PartialViewLocationFormats: @Html.RenderPartial("_PartialView", Model); will actually search the locations specified in PartialViewLocationFormats in the view engine, such as for example ~/Views/Home/_PartialView.cshtml ~/Views/Shared/_PartialView.cshtml However, when specifying the Layout, I seem to be forced to specify a specific path to the layout: @Layout = "~/Views/Shared/MyLayout.cshtml"; What I would like to do would be to specify the layout just by name, and have the the actual layout be found by searching a list of common locations: @Layout = "MyLayout"; ...but I can't find any facilities to do so. Since I could not find any documentation regarding this, I tried playing with setting RazorViewEngine.MasterLocationFormats, but this property is not used when locating layouts. Does anybody know how to do this?
Tags (comma-separated)
Save Edits
Cancel