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

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Create API endpoint

Create API endpoint

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

Start my 1-month free trial

Create API endpoint

- [Instructor] Now that we created our service and we set up the data file, it's time to create our first API endpoint, and we are going to start with the Create API endpoint. In here, go to the Controllers folder and create a new file. We are going to name this controller TripsController, so TripsController.cs. Let us next define the namespace and the namespace is going to be namespace Trips.controllers. Now inside here, let us create the C# class. So for that we just write public class TripsController, but for this class to be a controller, we need to inherit from the base class Controller. Let us import the namespace, so control dot, import the AspNetCore.Mvc, and inside this class, the first thing that we need to do is that we need to create a constructor so then we can inject the service to be able to use it in our endpoints. So the shortcut for that would be ctor then double tab. Let's change the class name to…

Contents