Handling requests using controllers and actions
Controllers are the fundamental blocks for handling requests for designing RESTful servicers using an ASP.NET Core web API. These are the primary classes that hold the logic to process requests, which includes retrieving data from a database, inserting a record into a database, and so on. Controllers are classes where we define methods to process requests. These methods usually include validating the input, talking to a data store, applying business logic (in enterprise applications, controllers will also call service classes), and—finally—serializing the response and sending it back to the client using HTTP protocols in JSON/XML form.
All these methods that hold the logic to process requests are known as actions. All requests received by the HTTP server are handed over to action methods using a routing engine. However, a routing engine transfers requests to actions based on certain rules that can be defined in a request...