6 The binding model: Retrieving and validating user input

This chapter covers

  • Using request values to create binding models
  • Customizing the model-binding process
  • Validating user input using DataAnnotations attributes

In chapter 5 I showed you how to define a route with parameters—perhaps for the day in a calendar or the unique ID for a product page. But say a user requests a given product page—what then? Similarly, what if the request includes data from a form, to change the name of the product, for example? How do you handle that request and access the values the user provided?

In the first half of this chapter, we’ll look at using binding models to retrieve those parameters from the request so that you can use them in your Razor Pages. ...

Get ASP.NET Core in Action, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.