MVC3:当部分视图位于不同的、未搜索的文件夹中时,如何指定加载它?
我试图在位于不同文件夹的视图中包含部分视图。所以我有以下观点:
/_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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的应用程序的根目录是 _mvc/ 文件夹,那么您需要做的就是:
在您的情况下,~ 已经指向 mvc_/。
If the root of your application is the _mvc/ folder, then all you should need to do is:
In your case, ~ already points to mvc_/.