Using Shared Layouts with Razor Pages
Learn about utilizing ASP.NET Core layouts for efficient management, demonstrating through creating a layout.
We'll cover the following...
We'll cover the following...
Most websites have more than one page. If every page had to contain all of the current boilerplate markup in index.cshtml, that would become a pain to manage. So, ASP.NET Core has a feature named layouts.
Method to use layouts
To use layouts, we must create a Razor file to define the default layout for all Razor Pages (and all MVC views) and store it in a Shared folder to easily find it by convention. The name of this file can be anything because we will specify it, but _Layout.cshtml is good practice. We must also create a specially named file to set the default layout file for all Razor Pages (and all MVC views). This file must be ...