From the course: Building Angular and ASP.NET Core Applications

Unlock the full course today

Join today to access over 24,500 courses taught by industry experts.

Create API endpoint

Create API endpoint

- [Narrator] Now that we set up this service, and we created the data file, which has the data that we will work with, it is time to create a controller which will have the API Endpoints that we are going to need. So, let's see this in action. In our solution, let's go to the Controllers folder and create a new controller. We are going to name this controller BooksController.cs. Inside here, let us define the namespace to be Summaries.Controllers and then inside here we are going to create our first controller. And the controller is just a class, so for that, we write in here public class BooksController. But for a class to be a controller, we need to inherit in this case from the controller base class. So for that we write in here colon and then Controller. Let us import the necessary name space for controller, which is the AspNetCore.mvc. Now, inside here, we are going to write all the code. First of…

Contents