From the course: Learning ASP.NET

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Create a consistent UI with layouts

Create a consistent UI with layouts

From the course: Learning ASP.NET

Start my 1-month free trial

Create a consistent UI with layouts

- [Instructor] Many websites that you're familiar with have content that displays on every page, like the header and footer. ASP.NET webpages offers a feature called Layout pages where you can place common content that's shared across the site. Let's take a look at the Layout file that was generated when we created our razor website. Open the underscore Site Layout file at the root of the application. In the head element we're including third party script libraries like jQuery so we don't have to include them in individual pages. Scrolling down, here's the header element where we can display things like the logo for the site. There's also a razor code block on line 22 with conditional logic to check if the user is authenticated and based on that, display different menu items. Let's inspect the code starting at line 47. This is where ASP.NET will insert content blocks into the Layout page. The Render Section Method is how you render a named section that's defined in a content page…

Contents