【发布时间】:2012-02-15 13:44:25
【问题描述】:
首先介绍一下上下文。当您调用 Html.RenderPartial 您发送视图名称时,将在 RazorViewEngine.PartialViewLocationFormats 指定的位置搜索该视图:
Html.RenderPartial("Post", item);
在 Razor 页面设置 Layout 属性时,不能只说名称,需要指定路径。我怎样才能只指定名称?
//Layout = "_Layout.cshtml";
Layout = "_Layout"; //Dont work
我需要这个,因为我覆盖了 RazorViewEngine.MasterLocationFormats。
目前我在控制器指定主控:
return View("Index", "_Layout", model);
这可行,但我更喜欢在 View 上执行此操作。
【问题讨论】:
标签: asp.net-mvc razor