Creating Controller Action Methods

Learn about the controller action methods.

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:

  1. Let’s create a method called GetQuestions at the bottom of the QuestionsController class:

Get hands-on with 1200+ tech skills courses.