我按照本教程来自定义部分视图位置。 http://www.leonamarant.com/2011/02/17/adding-a-custom-directory-to-razor-view-engine-partial-view-locations-in-asp-net-mvc3/
一切都很好,除了一件事:用控制器名称定义自定义位置 这是我的位置:
private static string[] customLocations = new[] {
"~/Views/{1}/{0}.cshtml", // It does not work
"~/Views/Shared/{0}.cshtml", // It works
"~/Views/Home/{0}.cshtml" // It works
};
在我看来,我只是添加了这一行,找不到局部视图:
@Html.Partial("Test/_MyPartial")
我知道我可以写一个相对路径来解决我的问题,但这行不需要我的班级“MyViewEngine.cs”
@Html.Partial("../Test/_MyPartial")
如何将控制器名称与{1}?
绑定