未找到可移植区域中的 ASP.NET MVC 部分

发布于 2024-09-16 18:18:26 字数 435 浏览 2 评论 0原文

我正在尝试在视图中包含部分内容。局部视图和视图都位于 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 技术交流群。

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

发布评论

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

评论(1

面犯桃花 2024-09-23 18:18:26

所有视图(以及部分视图和模板)必须是嵌入资源而不是内容文件。您可以在“构建操作”属性中定义它。要使部分资源成为嵌入资源,请在解决方案资源管理器中突出显示它并按 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.

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