โ† 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 attribute automatically binds a Razor Page's PageModel property to incoming HTTP POST form data?

    Answer: [BindProperty]

    [BindProperty] is the dedicated attribute for binding PageModel properties to form data on POST requests in Razor Pages.

  2. Which handler method signature handles HTTP GET requests in a Razor Pages PageModel?

    Answer: Both OnGet() and OnGetAsync() are valid

    Both synchronous OnGet() and asynchronous OnGetAsync() are valid handler methods for GET requests in Razor Pages.

  3. What Razor directive declares the model type for a Razor view, enabling IntelliSense and strong typing?

    Answer: @model

    The @model directive declares the C# type of the Model property available in the Razor view, enabling strong typing.

  4. Where are Razor Pages .cshtml files stored by default in an ASP.NET Core project?

    Answer: /Pages

    By convention, Razor Pages files are stored in the /Pages folder, and the folder structure maps directly to URL routes.

  5. What is the file extension for a Razor Page's code-behind PageModel file?

    Answer: .cshtml.cs

    The PageModel code-behind uses the .cshtml.cs extension, pairing it with the corresponding .cshtml view file.

  6. Which method should a PageModel return to redirect the user to a different Razor Page after processing a POST?

    Answer: return RedirectToPage()

    RedirectToPage() is the Razor Pages method for redirecting to another page, resolving routes relative to the Pages folder.

  7. What does the asp-page Tag Helper attribute do when applied to an anchor tag in a Razor view?

    Answer: Generates an href URL pointing to the specified Razor Page

    The asp-page tag helper generates the correct href URL for the specified Razor Page using ASP.NET Core's routing system.