MVC3:当部分视图位于不同的、未搜索的文件夹中时,如何指定加载它?

发布于 2024-12-01 05:06:24 字数 585 浏览 4 评论 0原文

我试图在位于不同文件夹的视图中包含部分视图。所以我有以下观点:

/_mvc/Views/Home/Index.cshtml

它有以下代码行:

@Html.Partial("~/_mvc/Views/Subject/_QuickSearch.cshtml", Model.QuickSearchModel);

这不起作用。我不断收到以下错误:

The partial view '~/_mvc/Views/Subject/_QuickSearch' was not found or no view 
engine supports the searched locations. The following locations were searched:
~/_mvc/Views/Subject/_QuickSearch

我是否遗漏了一些明显的东西?我应该指出,我已经修改了应用程序的路由,将所有 MVC 代码放在 _mvc 文件夹中。这不是一个错误。该应用程序正在从 WebForms 转换为 MVC,我希望将所有 MVC 内容放在一个文件夹下。

I am trying to include a partial view in a view that is located in a different folder. So I have the following view:

/_mvc/Views/Home/Index.cshtml

It has the following line of code:

@Html.Partial("~/_mvc/Views/Subject/_QuickSearch.cshtml", Model.QuickSearchModel);

This is not working. I keep getting the following error:

The partial view '~/_mvc/Views/Subject/_QuickSearch' was not found or no view 
engine supports the searched locations. The following locations were searched:
~/_mvc/Views/Subject/_QuickSearch

Am I missing something obvious? I should point out that I have modified the routing for my application to place all MVC code in the _mvc folder. This is not a mistake. The application is in the process of being converted from WebForms to MVC and I wanted all the MVC stuff under one folder.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玩物 2024-12-08 05:06:24

如果您的应用程序的根目录是 _mvc/ 文件夹,那么您需要做的就是:

@Html.Partial("~/Views/Subject/_QuickSearch.cshtml", Model.QuickSearchModel);

在您的情况下,~ 已经指向 mvc_/。

If the root of your application is the _mvc/ folder, then all you should need to do is:

@Html.Partial("~/Views/Subject/_QuickSearch.cshtml", Model.QuickSearchModel);

In your case, ~ already points to mvc_/.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文