Conclusions

The following conclusions can be made from the preceding observation. Note that we are talking about GET requests with the URL api/values, which means we are talking about all nonparameterized action methods in the controller. While reading the following points, ignore methods with parameters or other attributes:

  • When we access a particular Web API controller without any parameters (for example, api/values), action methods with the [HttpGet] attribute are searched first from the controller.
  • If an attribute is not mentioned in nonparameterized methods, then the .NET Core runtime will get confused when selecting one action method for the request.
  • There is no restriction on the naming convention of the action method. As long as it is the only method with no [HttpGet] attribute or the only method with an [HttpGet] attribute, it would be perfectly executed when GET request comes to the API.