Section 4: Creating a Controller (Restful API in ASP .Net Core)

 

Section 4: Creating a Controller


Introduction:


In the last section, we have seen how to create a model. By creating a model, we have defined a schema for our table using a class. But how to perform CRUD (Create/Read/Update/Data) data to the database?

We need a controller for that job.

Controller accepts the request, and process it and returns the data.

To add a controller, 

Right click on the Controller folder.
  • Select Controller -> "API Controller - Empty"
  • Rename the controller as MoviesController.cs.

The controller class should aways end with Controller keyword. This is the naming convention to be followed.


I show the above steps as below: