Creating Controller Action Methods
Explore how to create controller action methods in ASP.NET Core to handle HTTP requests. Learn to implement the GET method for fetching data and returning it as JSON, setting up your REST API endpoints effectively.
We'll cover the following...
We'll cover the following...
Action methods are where we can write code to handle requests to a resource. In this section, we are going to implement action methods that will handle requests to the questions resource. We will cover the GET, POST, PUT, and DELETE HTTP methods.
Creating an action method for getting questions
Let’s implement our first action method, which is going to return an array of all the questions. Open QuestionsController.cs and carry out the following steps: