首先有一点上下文。当你调用Html.RenderPartial您发送的视图名称,这一观点将在由RazorViewEngine.PartialViewLocationFormats指定位置搜索:如何设置剃刀布局文件,只需指定名称?
Html.RenderPartial("Post", item);
当您设置在剃刀页面布局属性,你不容只是说这个名字,你需要指定路径。我怎样才能指定名称?
//Layout = "_Layout.cshtml";
Layout = "_Layout"; //Dont work
我需要这个,因为我重写了RazorViewEngine.MasterLocationFormats。
目前我在控制器指定网站站长:
return View("Index", "_Layout", model);
这工作,但我更喜欢在查看做到这一点。
看这个问题http://stackoverflow.com/questions/5357104/is-is-possible-to-specify-searchable- location-formats-for-mvc-razor-layout – sarvesh 2012-02-15 02:05:08