【发布时间】:2016-10-18 13:57:27
【问题描述】:
我被要求在我正在构建的网页中添加公司页眉和页脚。设计团队给了我两个链接,一个是页眉,另一个是页脚。
我所做的是打开该链接,然后从检查器复制整个代码,添加到 _header.cshtml 和 _footer.cshtml 中。然后我将它们作为部分视图包含在 _layout.cshtml 中。我正在使用带有 MVC4 的 ASP.net。
该团队对页眉和页脚进行了一些更改,他们告诉我他们无法在我的页面中看到这些更改。
谁能指导我,让我知道我必须做什么才能使页眉和页脚从我收到的链接中动态工作。
这是我的代码:
<body>
<header>
<div>
@Html.Partial("_Header")
<!--#include virtual="/header.html"-->
</div>
</header>
<div id="body">
<section class="content-wrapper main-content clear-fix">
@RenderBody()
</section>
</div>
<footer>
<div>
@Html.Partial("_Footer")
<!--#include virtual="/footer.html"-->
</div>
</footer>
@RenderSection("scripts", required: false)
</body>
链接看起来像这样。 http://webapps.corporate.com/templates/corporate/contact/header.html
任何帮助将不胜感激。
【问题讨论】:
-
_Header 和 _Footer 是否在 _Layout 的同一位置?看看docs.asp.net/en/latest/mvc/views/partial.html
-
不,但我可以移动它们,这不是问题。页眉和页脚工作正常,因为它们只是部分视图,我的问题是如何使它们动态化(从外部链接获取页眉和页脚)?
-
您可能会发现简单地使用 iframe 会更容易。
标签: asp.net .net asp.net-mvc