6 Data validation and error handling
This chapter covers
- Overview of model binding and data validation
- Built-in and custom validation attributes
- ModelState validation approaches
- Error and exception handling techniques
For simplicity, up to this point we’ve assumed that the data coming from clients is always correct and adequate for our web API’s endpoints. Unfortunately, this is not always the case: whether we like it or not, we often have to deal with erroneous HTTP requests, which can be caused by several factors (including malicious attacks) but always occur because our application is facing unexpected or unhandled behavior.
In this chapter, we’ll discuss a series of techniques for handling unexpected scenarios during the client-server interaction. ...
Get Building Web APIs with ASP.NET Core 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.