Part 3 Generating HTML with Razor Pages and MVC

 

In parts 1 and 2 we looked in detail at how to create JavaScript Object Notation (JSON) API applications using minimal APIs. You learned how to configure your app from multiple sources, how to use dependency injection to reduce coupling in your app, and how to document your APIs with OpenAPI.

API apps are everywhere these days. Mobile apps use them; client-side single-page applications (SPAs) like Angular, React, and Blazor use them; even other apps use them for server-to-server communication. But in many cases you don’t need separate server-side and client-side apps. You could create a server-rendered app instead.

With server-rendering, your application generates the HTML on the server and the browser displays this HTML directly in the browser; no extra client-side framework is required. You can still add dynamic client-side behavior by using JavaScript, but fundamentally each page in your app is a standalone request and response, creating a simpler developer experience.

In part 3 you’ll learn about the Razor Pages and Model-View-Controller (MVC) frameworks that ASP.NET Core uses to create server-rendered apps. In chapters 13 through 16 we’ll examine the behavior of the Razor Pages framework itself, along with routing and model binding. In chapters 17 and 18 we’ll look at how you can build the UI for your application by using the Razor syntax and Tag Helpers so that users can navigate and interact with your app.