我正在使用 Visual Studio 构建 ASP.NET 网站。
我想在所有页面上重复使用页眉和页脚,而不是将 HTML 复制到所有页面。
我已经查看了以下答案,但它们都是为 PHP 编写的。有人可以帮助展示如何在 ASP.NET 中执行此操作吗?
最佳答案
你应该使用 ASP.NET Master Pages
为此目的:
ASP.NET master pages allow you to create a consistent layout for the pages in your application. A single master page defines the look and feel and standard behavior that you want for all of the pages (or a group of pages) in your application. You can then create individual content pages that contain the content you want to display. When users request the content pages, they merge with the master page to produce output that combines the layout of the master page with the content from the content page.
母版页让您可以集中页面的常用功能,这样您就可以在一个地方进行更新。
关于c# - 在所有网页上使用相同的页眉和页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33330735/