0

我按照本教程自定义了我的部分视图位置。 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} 绑定?

4

0 回答 0