13 Creating a website with Razor Pages

 

This chapter covers

  • Getting started with Razor Pages
  • Introducing Razor Pages and the Model-View-Controller (MVC) design pattern
  • Using Razor Pages in ASP.NET Core

So far in this book you’ve built one type of ASP.NET Core application: minimal API apps that return JavaScript Object Notation (JSON). In this chapter you’ll learn how to build server-rendered, page-based applications using Razor Pages. Most ASP.NET Core apps fall into one of three categories:

  • An API designed for consumption by another machine or in code—Web apps often serve as an API to backend server processes, to a mobile app, or to a client framework for building single-page applications (SPAs). In this case your application serves data in machine-readable formats such as JSON or Extensible Markup Language (XML) instead of the human-focused HTML output.
  • An HTML web application designed for direct use by users—If the application is consumed directly by users, as in a traditional web application, Razor Pages is responsible for generating the web pages that the user interacts with. It handles requests for URLs, receives data posted via forms, and generates the HTML that enables users to view and navigate your app.
  • Both an HTML web application and an API—It’s also possible to have applications that serve both needs, which can let you cater to a wider range of clients while sharing logic in your application.

13.1 Your first Razor Pages application

13.1.1 Using the Web Application template

13.1.2 Adding and configuring services

13.1.3 Generating HTML with Razor Pages

13.1.4 Handling request logic with page models and handlers

13.2 Exploring a typical Razor Page

13.3 Understanding the MVC design pattern

13.4 Applying the MVC design pattern to Razor Pages

13.4.1 Directing a request to a Razor Page and building a binding model

13.4.2 Executing a handler using the application model

13.4.3 Building HTML using the view model

sitemap