HTTP GET

Learn how to create action methods to obtain data via JSON Web APIs.

Get all data

Start off with an action method that is dealing with the GET requests. Call this method GetUsers().

Code

Press + to interact
// GET: api/Users
[HttpGet]
public async Task<ActionResult<IEnumerable<User>>> GetUsers()
{
return await _context.Users.ToListAsync();
}

Explanation

[HttpGet] informs the framework that this method is a GET method, and the framework provides routing accordingly. In this example, the route will be /Api/Users with the request type ...