3 Working with Razor Pages
This chapter covers
- Generating HTML with Razor templates
- Learning the Razor syntax
- Working with layouts, partials and Tag Helpers
- Understanding the PageModel as a controller and view model
- Working with handler methods and IActionResult
At this point, you should have a good understanding of the working parts of a Razor Pages application - how to create one, the role of the generated files, and how to configure the application’s behavior through the request pipeline. Now you are ready to take a deep dive into working with the principal actor within a Razor Pages application - the Razor page itself.
As you work through the chapter, you will learn how to use Razor syntax to generate dynamic HTML and coordinate layouts and partial files to reduce your repetition of code and improve reuse. You have already had a brief introduction to layouts and partials, but to remind you, layouts act as a kind of master template for multiple pages, and partial files consist of snippets of UI that can be plugged into a host page or layout.