Using Visual Studio 2017 and Visual Studio Code

In the Controllers folder, open ValuesController.cs, and note the following:

  • The [Route] attribute registers the /api/values relative URL for clients to use to make HTTP requests that will be handled by this controller. The /api/ base route followed by a controller name is a convention to differentiate between MVC and Web API. You do not have to use it. If you use [controller] as shown, it uses the characters before Controller in the class name, or you can simply enter a different name without the brackets.
  • The [HttpGet] attribute registers the Get method to respond to HTTP GET requests, and it returns an array of string values.
  • The [HttpGet] attribute with a parameter registers the Get method ...

Get C# 7.1 and .NET Core 2.0 – Modern Cross-Platform Development - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.