Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试创建一个 asp.net MVC 网站,并注意到由于共享布局模板,我创建的每个视图始终在顶部具有页眉和底部的页脚。有没有办法创建一个不遵循模板的视图?
你可以用很多方法做到这一点。以下是最常见的两种方式。
在您的控制器中,您可以..
return this.PartialView(model);
或者在你的视图中你可以(我不推荐这个..)
@{ Layout = null; }
您可以使用多种布局。只需创建没有 css 参考的第二个布局。
您可以像这样在视图顶部指定布局:
@{ Layout = "~/Views/Shared/_PublicLayout.cshtml"; }