未找到可移植区域中的 ASP.NET MVC 部分
我正在尝试在视图中包含部分内容。局部视图和视图都位于 MVC 可移植区域中。这是视图中的代码:
<% Html.RenderPartial("Here"); %>
这是部分视图(名为 Here.ascx,位于我的可移植区域的共享文件夹中):
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<p>
Here
</p>
<p>
You found me.
</p>
结果是: 未找到部分视图“Here”。我也尝试过指定该部分的相对路径,但没有运气。有什么想法吗?
I'm trying to include a partial in a view. Both the partial and the view are in an MVC Portable Area. Here's the code in the view:
<% Html.RenderPartial("Here"); %>
Here's the partial (named Here.ascx and located in the Shared folder of my portable area):
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<p>
Here
</p>
<p>
You found me.
</p>
The result is: The partial view 'Here' was not found. I've also tried specifying the relative path to this partial too, but with no luck. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所有视图(以及部分视图和模板)必须是嵌入资源而不是内容文件。您可以在“构建操作”属性中定义它。要使部分资源成为嵌入资源,请在解决方案资源管理器中突出显示它并按 F4 键,或者右键单击它并从上下文菜单中选择“属性”。
All views (and partials and templates) must be embedded resources rather than content files. You define this in the "Build Action" property. To make a partial an embedded resource, highlight it in Solution Explorer and press the F4 key, or right-click it and select Properties from the context menu.