โ† All ASP.NET Core Flashcard Decks

Razor Pages & Views Flashcards

7 cards from real ASP.NET Core practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 7 Razor Pages & Views flashcards as text
  1. What is the primary purpose of a Razor Layout page in ASP.NET Core?

    Answer: To define shared HTML structure like headers and footers reused across multiple views

    Layout pages define a common HTML structure (headers, footers, navigation) that multiple content views can share, eliminating repetition.

  2. Which file is conventionally used to set a default layout for all Razor views in a folder and its subfolders?

    Answer: _ViewStart.cshtml

    _ViewStart.cshtml executes before any view in the same folder and is typically used to set the Layout property globally.

  3. What does calling @RenderBody() inside a Razor Layout page accomplish?

    Answer: It inserts the content page's HTML at that location within the layout

    @RenderBody() is the placeholder in a layout where the child content page's unique HTML markup is rendered.

  4. How do named sections work between a layout page and a content page?

    Answer: @RenderSection() in the layout renders a section defined with @section in the content page

    @RenderSection('Name') in the layout defines where the section renders; @section Name { } in the content page supplies the HTML for that section.

  5. What is the purpose of _ViewImports.cshtml in an ASP.NET Core project?

    Answer: To share @using directives and @addTagHelper registrations across all views in a folder

    _ViewImports.cshtml provides shared @using, @addTagHelper, and other directives to all views in its folder and subfolders, avoiding repetition.

  6. Which mechanisms can pass data from a Razor Pages PageModel to its view beyond the strongly-typed Model property?

    Answer: ViewData, ViewBag, and TempData are all valid options

    ViewData (dictionary), ViewBag (dynamic wrapper over ViewData), and TempData all provide ways to pass data from a PageModel to its view.

  7. When using a standard HTML in a Razor Page without any asp-page attribute, where does the form submit to by default?

    Answer: The current Razor Page's OnPost handler

    In Razor Pages, a form with method='post' automatically targets the current page's OnPost handler method by default.